Skip to content

Handle cancelled request futures without overwriting their state - #35

Open
Aschenbath wants to merge 1 commit into
python-lsp:developfrom
Aschenbath:fix/oss20next-20261125-3592-jsonrpc-cancelled-futures
Open

Aschenbath wants to merge 1 commit into
python-lsp:developfrom
Aschenbath:fix/oss20next-20261125-3592-jsonrpc-cancelled-futures

Conversation

@Aschenbath

Copy link
Copy Markdown

Cancelling an outgoing request currently logs an InvalidStateError from its callback, and a late result or error response raises the same exception during dispatch. Cancelling an incoming request also tries to set an exception on an already-cancelled Future, preventing the cancellation response from being sent.

Keep Future cancellation intact, translate CancelledError into the JSON-RPC cancellation response for incoming requests, and ignore late responses only when the outgoing Future is cancelled, including a cancellation racing with delivery. Other invalid states still propagate.

Regression coverage includes outgoing cancellation, late result/error responses, incoming Futures cancelled before and after dispatch, and a running request that cannot be cancelled. Five cases fail on the unchanged source; the running-request control passes. The full suite passes on Linux/Python 3.12 (33 tests), along with pycodestyle, pyflakes, Pylint (10/10), and sdist/wheel builds.

AI disclosure: OpenAI Codex investigated the failures, wrote the patch and tests, and ran the reported validation. No independent human review is claimed.

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