Fix swallowed cursor error between batches in async iterator#1167
Open
dimssu wants to merge 1 commit intoporsager:masterfrom
Open
Fix swallowed cursor error between batches in async iterator#1167dimssu wants to merge 1 commit intoporsager:masterfrom
dimssu wants to merge 1 commit intoporsager:masterfrom
Conversation
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.
Fixes #1166.
When an error arrives on the connection between resolution of cursor batch
N and the consumer requesting batch N+1, the iterator's
next()previouslyoverrode
this.rejectwith a closure tied to the current batch's promise.That promise was already settled by
cursorFn, so the rejection was a no-op— only
this.active = falsetook effect. The nextnext()call thenshort-circuited via
this.executed && !this.activeand returned{ done: true }, silently completing the iteration with missing rows.This stores the error alongside the
active = falseflag and re-throws iton the next iteration, matching the behavior the caller would have seen had
the rejection landed during a pending batch.
Includes a regression test that simulates the race by triggering
query.rejectafter the first batch resolves and asserting the nextiterator step throws.