Repository navigation
fix: stop swallowing coroutine cancellation in GraphQLRequestHandler - #2223
Open
ujjawal-yadav wants to merge 1 commit into
Open
ujjawal-yadav wants to merge 1 commit into
ujjawal-yadav wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
📝 Description
GraphQLRequestHandler.executecatchesExceptionand turns it into an error response. On the JVM,CancellationExceptionis anException, so when the coroutine running the request is cancelled (for example by a timeout, or a client disconnect that cancels the request), the handler treats the cancellation as an ordinary execution error and keeps going. Batches that contain a mutation run sequentially, so the remaining operations still execute after the request has been cancelled.The catch block now calls
currentCoroutineContext().ensureActive(), so the handler rethrows only when its own coroutine has been cancelled. Every other exception, including aCancellationExceptionfrom a cancelled future while the request is still active, is still returned as a GraphQL error, as before.The new test cancels a batch of two mutations while the first is still running. On
masterthe second mutation executes; with this change it doesn't.🔗 Related Issues
Related to #1920. The original context-factory report no longer reproduces on
master; this fixes the cancellation case found in the same thread: #1920 (comment)