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

fix(lsp): Catch cancellation exceptions thrown by TSC, stop waiting for TS result upon cancellation #23645

Merged
merged 3 commits into from
May 2, 2024

Conversation

nathanwhit
Copy link
Member

@nathanwhit nathanwhit commented May 2, 2024

Fixes #23643.

We weren't catching the cancellation exception thrown by TSC on the JS side, so the rust side was catching this exception and then attempting to print out the exception via toString. That last bit resulted in a cryptic [object Object] showing up in the logs like so:

Error during TS request "getCompletionEntryDetails":
  [object Object]

I'm not 100% sure how we weren't seeing this in the past. My guess is that #23409 and the subsequent PR to improve the exception catching and logging surfaced this, but I'm still not quite clear on it.

My initial fix here returned null to rust when a server request was cancelled, but this resulted in a deserialization error when we attempted to deserialize that into the expected response type. So now, as soon as the request's cancellation token signals we'll stop waiting for a response and return an error (which will get swallowed as the LSP request is being cancelled).

I was a bit surprised to find that this branch actually executes sometimes, I believe due to the fact that aborting a future may not immediately stop its execution.

Copy link
Collaborator

@nayeemrmn nayeemrmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nathanwhit nathanwhit merged commit 66b66de into denoland:main May 2, 2024
17 checks passed
@nathanwhit nathanwhit deleted the catch-cancellation-lsp branch May 2, 2024 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LSP Errors in main
2 participants