fix(workflow-lsp): prevent uncaught 'Connection is disposed' during teardown#2385
Merged
curtisman merged 1 commit intoMay 22, 2026
Merged
Conversation
…eardown When the underlying transport is destroyed (common in jest tests), vscode-jsonrpc's pending messageWriter.write rejects and its .catch calls logger.error(...). The logger is the server's connection.console, whose send() invokes connection.sendNotification, which throws synchronously via throwIfClosedOrDisposed once the connection is disposed. That synchronous throw escapes the internal .catch and surfaces as an uncaught exception that crashes the worker. Neutralize connection.console in server.dispose() before disposing the connection so any post-dispose log attempts no-op instead of throwing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Intermittent CI failure in
examples/workflow/lsptests:Root cause
When the underlying transport is destroyed (common during jest teardown),
vscode-jsonrpc's pendingmessageWriter.write(...)promise rejects. Its internal.catchcallslogger.error(...). Thatloggeris the server'sconnection.console(aRemoteConsoleImpl), whosesend()invokesconnection.sendNotification(...), which throws synchronously viathrowIfClosedOrDisposed()once the connection is disposed. The synchronous throw escapes the internal.catchand surfaces as an uncaught exception that crashes the worker.Fix
In
server.dispose(), replaceconnection.console.{error,warn,info,log,debug}with no-ops before callingconnection.dispose(). Any post-dispose log attempts from the jsonrpc layer now no-op instead of throwing.Validation
Built and ran the LSP test suite 5 times in a row locally; all 121 tests pass on each run with no uncaught exceptions.