Avoid returning responses for cancelled requests #3021
Draft
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.
Motivation
Closes #3019
Based on the problem reported, some clients will retry requests that they themselves requested cancellation for. The specification has no mention of this and no guidance about what to do.
Rust Analyzer had the same issue, so I tried to follow their fix, which is apparently to completely ignore requests that were already cancelled.
This looks weird to me since the spec mentions cancelled requests should still return something. But maybe it's talking only about the first instance of the cancelled request and not retries?
Implementation
If my understanding is correct, Rust Analyzer's fix was to not return anything to the client when receiving a retry of a cancelled request. This PR does the same.
Automated Tests
Added a test.