Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect disposal of LSP connection due to access to undefined serverRequests #16185

Open
krassowski opened this issue Apr 18, 2024 · 0 comments

Comments

@krassowski
Copy link
Member

krassowski commented Apr 18, 2024

Description

Sometimes when switching kernels I see an uncaught error:

connection.ts:271 Uncaught (in promise) TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at LSPConnection.dispose (connection.ts:271:12)
    at DocumentConnectionManager.unregisterDocument (connection_manager.ts:428:20)
    at NotebookAdapter.disconnect (adapter.ts:304:30)
    at NotebookAdapter.reloadConnection (adapter.ts:397:10)
    at NotebookAdapter.onKernelChanged (notebooklspadapter.ts:209:12)

This is raised from:

dispose(): void {
if (this.isDisposed) {
return;
}
Object.values(this.serverRequests).forEach(request =>
request.clearHandler()
);

and happens because serverRequests have no initializer in constructor nor in class definition:

/**
* Responses comes from the server.
*/
serverRequests: ServerRequests;

These are only initialized after server initialization in afterInitialized:

this.serverRequests = this.constructServerRequestHandler<ServerRequests>(
Method.ServerRequest
);

Expected behavior

  • Disposal of connections which have not yet initialized does not raise an error.
  • There is a unit test case for this scenario

Context

  • JupyterLab version: 4.1.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants