Skip to content

Conversation

@ahoppen
Copy link
Member

@ahoppen ahoppen commented Jan 4, 2026

Currently, when implicitly cancelling requests because a document has been changed, we return an error response that indicates that the client cancelled the request because we translated all CancellationError to this response. The more accurate response is to indicate that the content has been modified, returning a ContentModified error.

To do so, we need to make two changes:

  • QueueBasedMessageHandler needs to keep track of the reasons why it cancelled request handling tasks
  • The protocol requirement QueueBasedMessageHandler.handle(request:id:reply) needs to allow returning CancellationError instead of eagerly transforming it to a ResponseError in RequestAndReply. This is an API-breaking change. I haven’t found a great way to add a compatibility layer, so I propose that we need to have linked PRs in SourceKit-LSP and SwiftPM that need to be merged when we are updating the swift-tools-protocols version in the toolchain.

This is a prerequisite to fixing swiftlang/sourcekit-lsp#2136 (comment).

PRs that need to be merged when this gets picked up in toolchain builds:

…turned to clients

Currently, when implicitly cancelling requests because a document has been changed, we return an error response that indicates that the client cancelled the request because we translated all `CancellationError` to this response. The more accurate response is to indicate that the content has been modified, returning a `ContentModified` error.

To do so, we need to make two changes:
- `QueueBasedMessageHandler` needs to keep track of the reasons why it cancelled request handling tasks
- The protocol requirement `QueueBasedMessageHandler.handle(request:id:reply)` needs to allow returning `CancellationError` instead of eagerly transforming it to a `ResponseError` in `RequestAndReply`. This is an API-breaking change. I haven’t found a great way to add a compatibility layer, so I propose that we need to have linked PRs in SourceKit-LSP and SwiftPM that need to be merged when we are updating the swift-tools-protocols version in the toolchain.
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.

2 participants