deno/cli/lsp
Nathan Whitaker 66b66de96a
fix(lsp): Catch cancellation exceptions thrown by TSC, stop waiting for TS result upon cancellation (#23645)
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](0c671c9792/cli/lsp/tsc.rs (L1093))
actually executes sometimes, I believe due to the fact that aborting a
future may not [immediately stop its
execution](https://docs.rs/futures/latest/futures/stream/struct.AbortHandle.html#method.abort).
2024-05-01 20:31:11 -07:00
..
testing perf(lsp): only store parsed sources for open documents (#23454) 2024-04-20 02:00:03 +01:00
analysis.rs Revert "refactor(lsp): move fields from Documents to LspResolver" (#23626) 2024-05-01 05:54:25 +00:00
cache.rs perf: v8 code cache (#23081) 2024-04-17 07:19:55 -07:00
capabilities.rs chore(lsp): rename client-side command invocations (#22140) 2024-01-28 21:56:45 +00:00
client.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
code_lens.rs chore: enable clippy unused_async rule (#22834) 2024-03-11 23:48:00 -04:00
completions.rs chore(lsp): remove ConfigSnapshot (#23579) 2024-04-27 21:35:41 +01:00
config.rs chore(lsp): revert import map pre-resolution for jsxImportSource (#23619) 2024-05-01 01:44:20 +01:00
diagnostics.rs Revert "refactor(lsp): move fields from Documents to LspResolver" (#23626) 2024-05-01 05:54:25 +00:00
documents.rs Revert "refactor(lsp): move fields from Documents to LspResolver" (#23626) 2024-05-01 05:54:25 +00:00
jsr.rs refactor: move redirect handling into deno_graph (#23444) 2024-04-19 01:43:28 +00:00
language_server.rs Revert "refactor(lsp): move fields from Documents to LspResolver" (#23626) 2024-05-01 05:54:25 +00:00
logging.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
lsp_custom.rs fix(lsp): don't normalize urls in cache command params (#22182) 2024-01-30 17:17:34 +00:00
mod.rs refactor(lsp): unify resolver types into LspResolver (#23514) 2024-04-26 21:39:33 +01:00
npm.rs refactor: move redirect handling into deno_graph (#23444) 2024-04-19 01:43:28 +00:00
parent_process_checker.rs fix(lsp): use a dedicated thread for the parent process checker (#21869) 2024-01-09 11:36:03 -05:00
path_to_regex.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
performance.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
README.md docs: fix broken deno manual link (#20667) 2023-09-25 14:09:27 +02:00
refactor.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
registries.rs refactor: move redirect handling into deno_graph (#23444) 2024-04-19 01:43:28 +00:00
repl.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
resolver.rs Revert "refactor(lsp): move fields from Documents to LspResolver" (#23626) 2024-05-01 05:54:25 +00:00
search.rs feat(lsp): jsr specifier completions (#22612) 2024-02-29 03:54:16 +00:00
semantic_tokens.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
text.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
tsc.rs fix(lsp): Catch cancellation exceptions thrown by TSC, stop waiting for TS result upon cancellation (#23645) 2024-05-01 20:31:11 -07:00
urls.rs refactor: load bytes in deno_graph (#22212) 2024-02-01 03:15:22 +00:00

Deno Language Server

The Deno Language Server provides a server implementation of the Language Server Protocol which is specifically tailored to provide a Deno view of code. It is integrated into the command line and can be started via the lsp sub-command.

This documentation has been moved to the Deno manual.