From 57de64f4f2cfa713319783c0680395a836722adf Mon Sep 17 00:00:00 2001 From: eitsupi Date: Tue, 17 Nov 2026 14:55:06 +0000 Subject: [PATCH 1/2] test: cover a bundled client's pending shutdown rejection in Interactive cleanup --- src/test/suite/interactiveEditor.test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/test/suite/interactiveEditor.test.ts b/src/test/suite/interactiveEditor.test.ts index 7dbd17997..ffe6aa8dc 100644 --- a/src/test/suite/interactiveEditor.test.ts +++ b/src/test/suite/interactiveEditor.test.ts @@ -5019,6 +5019,30 @@ suite('Interactive language client cleanup', () => { } }); + test('accepts a pending shutdown rejected by the extension bundle', async () => { + // The extension bundles vscode-languageclient, so its clients reject with + // a ResponseError class that is distinct from the one this test imports. + class BundledResponseError extends Error { + constructor( + readonly code: number, + message: string, + ) { + super(message); + } + } + const client = { + state: State.Stopped, + stop: () => + Promise.reject( + new BundledResponseError( + ErrorCodes.PendingResponseRejected, + 'Pending response rejected since connection got disposed', + ), + ), + } as unknown as LanguageClient; + await stopLanguageClient(client); + }); + test('does not suppress unrelated shutdown failures or an unstopped client', async () => { const error = Object.assign(new Error('Socket shutdown failed'), { code: 'EPIPE' }); const pending = new ResponseError( From f9061b888e655d9b8e1630418a81b810516fc0dc Mon Sep 17 00:00:00 2001 From: eitsupi Date: Tue, 17 Nov 2026 14:55:58 +0000 Subject: [PATCH 2/2] test: match language client stop errors by code across the extension bundle --- src/test/suite/interactiveEditor.test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/suite/interactiveEditor.test.ts b/src/test/suite/interactiveEditor.test.ts index ffe6aa8dc..2d08acde8 100644 --- a/src/test/suite/interactiveEditor.test.ts +++ b/src/test/suite/interactiveEditor.test.ts @@ -4897,11 +4897,13 @@ async function stopLanguageClient(client: LanguageClient): Promise { // R's language server can close on shutdown before the client's exit // notification is written (EPIPE), or, as seen on Windows, before its // shutdown response arrives. The client has already completed cleanup. + // Match by code: the extension bundles its own vscode-languageclient, + // so its ResponseError is not an instance of the class imported here. if ( client.state === State.Stopped && - ((error instanceof ResponseError && - error.code === ErrorCodes.PendingResponseRejected) || - (error instanceof Error && 'code' in error && error.code === 'EPIPE')) + error instanceof Error && + 'code' in error && + (error.code === ErrorCodes.PendingResponseRejected || error.code === 'EPIPE') ) { return; }