Skip to content

fix: avoid request-future mutation during shutdown - #642

Open
AryanRG wants to merge 1 commit into
openlawlibrary:mainfrom
AryanRG:fix/shutdown-cancel-futures-snapshot
Open

AryanRG wants to merge 1 commit into
openlawlibrary:mainfrom
AryanRG:fix/shutdown-cancel-futures-snapshot

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Description

Addresses #606. When shutdown cancels a queued threaded request, its future callback removes an entry from _request_futures while lsp_shutdown is iterating that dictionary. This raises RuntimeError; the shutdown request receives an internal-error response and the protocol does not enter its shutdown state.

Iterate a snapshot of the futures instead. The regression keeps one worker occupied, queues two more requests, then checks that shutdown succeeds, the queued requests are cancelled, and callback cleanup completes.

Validation

  • The new regression fails on the unchanged base on Python 3.9 and 3.13, and passes with this change.
  • Full local suite on each version: 289 passed, 7 skipped.
  • TCP end-to-end suite on Python 3.13: 74 passed. WebSocket end-to-end suite: 73 passed, 1 skipped.
  • Ruff, Black, mypy, generated-code comparison, and whitespace checks passed.

Local runs were on macOS; hosted CI will cover other platforms and versions. uv lock --check --offline failed identically on base and this branch with local uv 0.13.1; the lockfile is unchanged. AI assistance was used to prepare and validate this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant