🐛 Stop the LSP shutdown context-canceled log

The TS 7 Go server races Session.updateWatches against the exit
notification; handleExit returns io.EOF, the background context is
cancelled, and the bare error is flushed to stderr once the outgoing
queue closes (server.go / logger.go). Send shutdown and close stdin
instead: EOF makes the server exit cleanly (code 0, no output), with the
kill kept as a fallback. testing.md records the cause.
This commit is contained in:
tmu committed 2026-09-18 07:31:04 +00:00
1 parent 13497d1df8
commit 8b73143740
2 files changed
+24 -16

No files matched your search

+17 -12
View File
@@ -11,7 +11,6 @@ import {
ConfigurationRequest,
createMessageConnection,
DidOpenTextDocumentNotification,
ExitNotification,
InitializedNotification,
InitializeRequest,
type MessageConnection,
@@ -140,18 +139,24 @@ export class LspSession {
);
}
/** `shutdown` + `exit`, then kill the server; safe after a failed probe. */
/** `shutdown` + close stdin, then kill the server; safe after a failed probe. */
public close(): Promise<void> {
return this.#connection
.sendRequest(ShutdownRequest.type)
.then(() =>
this.#connection.sendNotification(ExitNotification.type),
)
.then(() => delay(EXIT_DELAY_MS))
.finally(() => {
this.#connection.dispose();
this.#child.kill();
});
return (
this.#connection
.sendRequest(ShutdownRequest.type)
// The TS 7 Go server races a background task against the `exit`
// notification and logs a bare `context canceled` to stderr as it
// tears down (see development/testing.md § Autocomplete). EOF on
// stdin shuts it down cleanly instead: exit 0, no output.
.then(() => {
this.#child.stdin.end();
})
.then(() => delay(EXIT_DELAY_MS))
.finally(() => {
this.#connection.dispose();
this.#child.kill();
})
);
}
#ensureInitialized(): Promise<void> {