Skip to content

Document diagnostic pull stops for a document after its pull request fails #1898

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:

  1. The request fails with a non-cancellation error (for example, the server's textDocument/diagnostic handler throws). The active entry is left behind. Every later pull for that document sees it as in flight, so it only cancels the dead token and marks the entry reschedule. No request is sent again for the rest of the session.
  2. The server cancels with DiagnosticServerCancellationData { retriggerRequest: false }. The outDated branch sets afterState, but the next if (afterState === undefined && error instanceof CancellationError) is then false, so the code falls into throw 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();
  1. Open a plaintext editor. The client sends request #1 and the server fails it.
  2. 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

Activity

  1. trivikr commented on Oct 20, 2026

    @trivikr
    ContributorAuthor

    A fix is proposed at #1899

  2. added this to the milestone on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions