jupyter-ai icon indicating copy to clipboard operation
jupyter-ai copied to clipboard

Error in handling closed websocket for inline completer

Open krassowski opened this issue 2 months ago • 0 comments

Description

When websocket gets disconnected we see:

Uncaught TypeError: Cannot read properties of undefined (reading '_reject')
    at reject (jlab_core.0c882064cb12a87cda90.js?v=0c882064cb12a87cda90:1:1731169)
    at we._onClose (392.e7fabd325dafbe2024f7.js?v=e7fabd325dafbe2024f7:1:37258)
    at i.onclose (392.e7fabd325dafbe2024f7.js?v=e7fabd325dafbe2024f7:1:37860)

Reproduce

This comes from:

https://github.com/jupyterlab/jupyter-ai/blob/3bfce328e3b6f730d05faa68ca9b6d6434b5fdec/packages/jupyter-ai/src/completions/handler.ts#L113-L123

Because the reject delegate is not bound to promise instance here:

https://github.com/jupyterlab/jupyter-ai/blob/3bfce328e3b6f730d05faa68ca9b6d6434b5fdec/packages/jupyter-ai/src/completions/handler.ts#L140

Expected behavior

No error in onClose handling.

Context

  • Operating System and version:
  • Browser and version:
  • JupyterLab version:
Troubleshoot Output
Paste the output from running `jupyter troubleshoot` from the command line here.
You may want to sanitize the paths in the output.
Command Line Output
Paste the output from your command line running `jupyter lab` here, use `--debug` if possible.
Browser Output
Paste the output from your browser Javascript console here, if applicable.

krassowski avatar Apr 11 '24 16:04 krassowski