fix: Prevent InvalidStateError when resolving canceled futures#2339
Merged
patrick91 merged 1 commit intostrawberry-graphql:mainfrom Nov 15, 2022
Merged
fix: Prevent InvalidStateError when resolving canceled futures#2339patrick91 merged 1 commit intostrawberry-graphql:mainfrom
patrick91 merged 1 commit intostrawberry-graphql:mainfrom
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2339 +/- ##
=======================================
Coverage 98.00% 98.00%
=======================================
Files 164 164
Lines 6666 6668 +2
Branches 1265 1266 +1
=======================================
+ Hits 6533 6535 +2
Misses 65 65
Partials 68 68 |
Member
|
Thanks for adding the Here's a preview of the changelog: This release changes the dataloader batch resolution to avoid resolving Here's the preview release card for twitter: Here's the tweet text: |
patrick91
approved these changes
Nov 15, 2022
Comment on lines
-260
to
+261
| await c4 == 4.4 | ||
| assert await c4 == 4.4 |
ben-xo
added a commit
to mixcloud/strawberry
that referenced
this pull request
Mar 10, 2026
The error path in `dispatch_batch` called `set_exception` on every future in the batch without checking if any had already been cancelled. When a client disconnects mid-request, some DataLoader futures get cancelled by the event loop; if the batch load function then fails (e.g. because the executor was torn down), the error handler would crash with `InvalidStateError` trying to set an exception on the cancelled futures. The success path already had this guard (added in strawberry-graphql#2339) but the error path was missed. This adds the same `cancelled()` check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ben-xo
added a commit
to mixcloud/strawberry
that referenced
this pull request
Mar 10, 2026
The error path in `dispatch_batch` called `set_exception` on every future in the batch without checking if any had already been cancelled. When a client disconnects mid-request, some DataLoader futures get cancelled by the event loop; if the batch load function then fails (e.g. because the executor was torn down), the error handler would crash with `InvalidStateError` trying to set an exception on the cancelled futures. The success path already had this guard (added in strawberry-graphql#2339) but the error path was missed. This adds the same `cancelled()` check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 task
ben-xo
added a commit
to mixcloud/strawberry
that referenced
this pull request
Mar 10, 2026
The error path in `dispatch_batch` called `set_exception` on every future in the batch without checking if any had already been cancelled. When a client disconnects mid-request, some DataLoader futures get cancelled by the event loop; if the batch load function then fails (e.g. because the executor was torn down), the error handler would crash with `InvalidStateError` trying to set an exception on the cancelled futures. The success path already had this guard (added in strawberry-graphql#2339) but the error path was missed. This adds the same `cancelled()` check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ben-xo
added a commit
to mixcloud/strawberry
that referenced
this pull request
Mar 10, 2026
The error path in `dispatch_batch` called `set_exception` on every future in the batch without checking if any had already been cancelled. When a client disconnects mid-request, some DataLoader futures get cancelled by the event loop; if the batch load function then fails (e.g. because the executor was torn down), the error handler would crash with `InvalidStateError` trying to set an exception on the cancelled futures. The success path already had this guard (added in strawberry-graphql#2339) but the error path was missed. This adds the same `cancelled()` check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ben-xo
added a commit
to mixcloud/strawberry
that referenced
this pull request
Mar 10, 2026
The error path in `dispatch_batch` called `set_exception` on every future in the batch without checking if any had already been cancelled. When a client disconnects mid-request, some DataLoader futures get cancelled by the event loop; if the batch load function then fails (e.g. because the executor was torn down), the error handler would crash with `InvalidStateError` trying to set an exception on the cancelled futures. The success path already had this guard (added in strawberry-graphql#2339) but the error path was missed. This adds the same `cancelled()` check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.


I see this error from time to time in my sentry installation: https://sentry.2u.app.br/share/issue/2c7efa8ad15145dd862cd2a95e455c98/