1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:24:41 -07:00
go/internal/lsp/protocol
Hana (Hyang-Ah) Kim 625332f3c5 internal/lsp/protocol: send responses for cancelled requests
LSP https://microsoft.github.io/language-server-protocol/specifications/specification-current/#cancelRequest
expects the server to send back the response even when the request is cancelled.

Gopls LSP protocol implements the cancellation using the context cancellation.
That is, upon a cancellation request from the client, the server calls the
corresponding canceller that cancels the context passed to the handler.
Reusing this cancelled context for the replyer is not safe because code in any layer
can decide to shortcircuit and skip sending the data back to the client.
E.g. https://cs.opensource.google/go/tools/+/master:internal/jsonrpc2/stream.go;l=63

This CL make sure to pass the detached context to the replier.

Alternative, or a better approach to avoid any unexpected side-effect of
using a detached context is to send out the response at the point of cancellation
with a separate context. But that requires more significant code change.

Testing is currently hard, but maybe doable once the current refactoring is
done. Test is left as a TODO.

Change-Id: I4611af00ad913e96b62c6b7180c6673b0465daf9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/232300
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2020-05-07 15:26:07 +00:00
..
typescript internal/jsonrpc2: add concrete types for Call, Notify and Response 2020-04-20 21:05:32 +00:00
context.go internal/event: remove the event.eventType type 2020-04-27 15:30:19 +00:00
doc.go internal/lsp: the core lsp protocol 2018-09-25 15:17:08 +00:00
enums.go internal/lsp: remove duplicated enums 2019-09-25 15:30:23 +00:00
log.go internal/jsonrpc2: move the lock into logCommon 2020-04-30 04:03:07 +00:00
protocol.go internal/lsp/protocol: send responses for cancelled requests 2020-05-07 15:26:07 +00:00
span.go internal/span,lsp: disambiguate URIs, DocumentURIs, and paths 2020-02-14 22:51:03 +00:00
tsclient.go internal/jsonrpc2: add concrete types for Call, Notify and Response 2020-04-20 21:05:32 +00:00
tsprotocol.go internal/jsonrpc2: change handler to a function type 2020-04-06 13:48:45 +00:00
tsserver.go internal/jsonrpc2: add concrete types for Call, Notify and Response 2020-04-20 21:05:32 +00:00