Repository navigation
Closed
Description
Version
vscode-languageclient 10.1.2 (main @ 8e797f4)
VS Code 1.140.0
macOS 26.7.1
Problem
In DiagnosticRequestor.pullAsync, two failure cases rethrow the error before the request's openRequests entry is removed:
- The request fails with a non-cancellation error (for example, the server's
textDocument/diagnostichandler throws). Theactiveentry is left behind. Every later pull for that document sees it as in flight, so it only cancels the dead token and marks the entryreschedule. No request is sent again for the rest of the session. - The server cancels with
DiagnosticServerCancellationData { retriggerRequest: false }. TheoutDatedbranch setsafterState, but the nextif (afterState === undefined && error instanceof CancellationError)is then false, so the code falls intothrow error. The client logs "Document pull failed", which is wrong for a deliberate cancellation, and the document gets stuck the same way as in case 1.
Steps to reproduce
Server (server.ts, using vscode-languageserver/node):
import { createConnection, DocumentDiagnosticReportKind, LSPErrorCodes, ResponseError, TextDocumentSyncKind } from 'vscode-languageserver/node';
// REPRO_MODE=error: the first pull throws. REPRO_MODE=cancel: the first pull is
// cancelled with retriggerRequest: false. Every later pull succeeds.
const mode = process.env.REPRO_MODE === 'cancel' ? 'cancel' : 'error';
const connection = createConnection();
let requests = 0;
connection.onInitialize(() => ({
capabilities: {
textDocumentSync: TextDocumentSyncKind.Full,
diagnosticProvider: { interFileDependencies: false, workspaceDiagnostics: false }
}
}));
connection.languages.diagnostics.on((params) => {
requests++;
connection.console.log(`textDocument/diagnostic #${requests} for ${params.textDocument.uri}`);
if (requests === 1) {
if (mode === 'cancel') {
throw new ResponseError(LSPErrorCodes.ServerCancelled, 'Server cancelled', { retriggerRequest: false });
}
throw new Error('Diagnostics failed');
}
return { kind: DocumentDiagnosticReportKind.Full, items: [] };
});
connection.listen();Client:
const client = new LanguageClient('repro', 'Repro', {
module: serverModule,
transport: TransportKind.ipc,
options: { env: { ...process.env, REPRO_MODE: 'error' } } // or 'cancel'
}, {
documentSelector: [{ language: 'plaintext' }],
diagnosticPullOptions: { onChange: true }
});
await client.start();- Open a plaintext editor. The client sends request
#1and the server fails it. - Type a character in the editor.
Expected
The edit sends textDocument/diagnostic request #2. With REPRO_MODE=cancel, nothing is logged as a failure.
What happens
No request is sent after the edit, and none are sent for that document for the rest of the session. In both modes the client logs "Document pull failed for text document untitled:Untitled-1". Counted with a pass-through provideDiagnostics middleware:
REPRO_MODE |
Requests before edit | After edit | "Document pull failed" logged |
|---|---|---|---|
error |
1 | 1 | 1 |
cancel |
1 | 1 | 1 |
Metadata
Metadata
Assignees
Labels
No labels
Activity
trivikr commentedon Oct 20, 2026
A fix is proposed at #1899