Repository navigation
fix(client): queries batched after a failing one reject instead of resolving undefined - #30544
Merged
wmadden-electric merged 3 commits intoNov 17, 2026
Conversation
Signed-off-by: lazerg <[email protected]>
Contributor
Contributor
Author
|
@wmadden, please have a look when you have time |
Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…the original error The regression test now asserts that both the failing create and the findMany that never ran reject with the unique constraint error (P2002), not just that they reject. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
wmadden-electric
enabled auto-merge (squash)
November 11, 2026 10:58
wmadden
approved these changes
Nov 17, 2026
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.
In Prisma 7, a query that never ran because an earlier query in its batch failed now rejects with that earlier error.
What went wrong
Inside an interactive transaction, queries sent in the same tick are batched together.
ClientEngine.requestBatchruns the batch's plans in order and stops at the first failure. It then returned a results array shorter than the list of requests.DataLoaderresolves every request past the end of that array withundefined. So queries that never ran looked like they succeeded and returned nothing.I reproduced this on Postgres 16 with
@prisma/adapter-pg, in three ways: a failed$queryRawfollowed by more queries, a unique-constraint failure followed by afindMany, and two queries on a transaction that had already rolled back. Every query after the failure resolvedundefined.The fix
requestBatchfills the rest of the results with the error that stopped the batch. So every query that didn't run rejects with the original error code, the same way the whole batch rejects whenrequestBatchthrows.$transaction([...])still rejects with the original error. A batch offindUniqueOrThrowcalls outside a transaction still runs every query, as #29654 made it do.Tests
interactive-transactionsfunctional suite: the new test "batching rejects queries after a failed one within callback" fails onv7(thefindManyresolvesundefined) and passes here. It runs against every provider in CI.Alternatives considered
Fixes #30540