Repository navigation
Conversation
…tions early The analysis, the parsing of the document's statements before it, and the snapshot that completions and hover build from the statements before the cursor check every 64 statements whether the document changed or the request was cancelled, and stop. Diagnostics of an outdated version are not published anyway, and code actions and completions answer ContentModified or are cancelled.
This was referenced Oct 26, 2026
Collaborator
Author
|
Superseded by #1008 (rebuild of the document caches and walk). |
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.
Stacked on #957.
#954 made cancelled hover, inlay hint and semantic token requests stop their walk. Two follow-ups were left: whether cancellation reaches the server the way editors actually run it, and diagnostics, lint code actions and completions, which always ran to the end.
How editors run the server: cancellation already reaches it
postgres-language-server-vscode,src/session.ts) starts the binary withlsp-proxy. So do nvim-lspconfig'spostgres_lsp(cmd = { 'postgres-language-server', 'lsp-proxy' }), lsp-mode'slsp-postgres, and the Helix/Zed setups indocs/guides/ide_setup.md.lsp-proxy(pgls_cli/src/commands/daemon.rs) only copies the LSP bytes between stdio and the daemon's socket. The daemon runs the language server itself (ServerFactory::new→LSPServer), with the workspace server in the same process (workspace::server_sync).$/cancelRequestreaches tower-lsp in the daemon, which drops the request future. The handler runs on a blocking thread in the daemon process, wherepgls_workspace::cancellationfrom perf(lsp): stop cancelled requests, and run diagnostics, completions and formatting off the runtime #954 works.WorkspaceClient), where a cancellation would be lost, is only used by CLI commands run with--use-server. Those have nothing to cancel.Stale analysis stops early
Analyser::analyse_until(params, should_stop)checksshould_stopevery 64 statements and returns early withAnalysisResult::stopped.analyseisanalyse_untilwith a check that never stops, so the CLI and the tests are unchanged.analyse_documentpasses "the document changed, or the request was cancelled", and checks the same every 64 statements while parsing the statements before the analysis.pull_file_diagnosticsreturns nothing and skips the database checks (EXPLAIN, plpgsql_check).run_document_requestsince perf(lsp): run editor requests off the async runtime on a snapshot of the document #931).snapshot_before, which completions and hover build from the statements before the cursor, does the same check while collecting and applying statements. It returns the database snapshot as is, which is never cached; the request ends withContentModifiedor is cancelled anyway.pgls_completions::completeitself works on one statement and isn't interrupted.Tests
pgls_analyser:analysis_stops_when_asked. 200 statements; asked to stop at the second check, it returns the 127 statements before it andstopped.pgls_workspace:test_cancelled_analysis_stops. Under a cancelled flag, diagnostics and lint code actions of a 200-statement file are empty; without it they're all there.ServerFactory/LSPServerthat the LSP tests use. A test that sends$/cancelRequestneeds a test client that can send a notification while it awaits a request, which ours can't.Not covered
The
--use-serverCLI path still can't be cancelled (nothing sends a cancellation there).