Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions ts/examples/workflow/lsp/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,27 @@ export function createServer(
dispose: () => {
for (const t of pendingDiagnostics.values()) clearTimeout(t);
pendingDiagnostics.clear();
// Neutralize the connection's logger before disposing. The
// jsonrpc layer calls `logger.error(...)` from the `.catch`
// of pending `messageWriter.write` promises when the
// underlying stream is torn down (common in tests). That
// logger is `connection.console`, whose `send()` invokes
// `connection.sendNotification`, which throws synchronously
// once the connection is disposed. The throw escapes the
// internal `.catch` and surfaces as an uncaught exception.
// Replacing the log methods with no-ops avoids that race.
const noop = () => {};
try {
Object.assign(connection.console, {
error: noop,
warn: noop,
info: noop,
log: noop,
debug: noop,
});
} catch {
// Ignore: console may already be inaccessible.
}
connection.dispose();
},
};
Expand Down
Loading