Repository navigation
Make a failed server cursor read reject instead of ending the cursor - #13
Draft
mark1russell7 wants to merge 1 commit into
Draft
mark1russell7 wants to merge 1 commit into
mark1russell7 wants to merge 1 commit into
Conversation
Since 3.3.1, AsynchronousCursor._rawNextObjectPromise awaited next() inside a try that only logged the error. A read that failed ended the cursor as if it had no more documents, so fetchAsync resolved with the documents read so far, findOneAsync with undefined, and forEachAsync stopped early. _rawNextObjectPromise now rethrows the error. A next() that fails while the cursor is closing still ends the cursor, because close() waits for the pending next(). _nextObjectPromiseWithTimeout cancels its timer with then(cancel, cancel) instead of finally(). finally() returned a second promise that rejected with the same error and had no handler. Fixes meteor#14794. Co-Authored-By: Claude Opus 5.5 (1M context) <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.
Summary
Fixes meteor#14794.
Since 3.3.1 (meteor#13786),
AsynchronousCursor._rawNextObjectPromiseawaitsnext()inside atrythat only logs. A read that fails ends the cursor as if it had no more documents. On the server,fetchAsyncresolves with the documents read so far, often[],findOneAsyncresolves withundefined, andforEachAsyncstops early. A caller can't tell a failed read from an empty result.Meteor's own callers already handle these errors, but never get them:
queryError.tail()restarts its cursor.Changes
_rawNextObjectPromiserethrows the error. Anext()that fails while the cursor is closing still ends the cursor, becauseclose()waits for the pendingnext()._nextObjectPromiseWithTimeoutcancels its timer withthen(cancel, cancel)instead offinally().finally()returned a second promise that rejected with the same error and had no handler, so every failed timed read became an unhandled rejection.tests/asynchronous_cursor_tests.js.Verification
The
mongopackage's server tests (test-server-tests-in-console-once), run twice:next()that fails while the cursor closes, passes either way: it guards behavior thatclose()already has.