Skip to content

test(NODE-7513): relax regression test for emptyGetMore#4916

Merged
tadjik1 merged 3 commits intomainfrom
NODE-7513
Apr 14, 2026
Merged

test(NODE-7513): relax regression test for emptyGetMore#4916
tadjik1 merged 3 commits intomainfrom
NODE-7513

Conversation

@tadjik1
Copy link
Copy Markdown
Member

@tadjik1 tadjik1 commented Apr 10, 2026

Description

Summary of Changes

Remove the emptyGetMore spy assertion from the NODE-6878 regression test. The test now only verifies that cursor.rewind() works correctly after cursor exhaustion via limit, which is the actual regression being guarded.

Notes for Reviewers

On MongoDB 9.0+, mongos now returns cursorId: 0 on the getMore that delivers the final batch when a limit is reached. This means the driver's emptyGetMore optimization (which avoids a wasted getMore when the server returns a non-zero cursorId after the limit is satisfied) is never triggered on sharded topologies with 9.0+.

The spy assertion required emptyGetMore to be called, which can no longer happen on 9.0. The original comment noted that without the spy, "this test always passes, even without the fix in NODE-6878" - that was true because if emptyGetMore was never called, the buggy (incomplete) response object was never used, so rewind() would succeed trivially. Now that the NODE-6878 fix is merged and emptyGetMore is a proper CursorResponse, the spy is no longer needed as a guard against a vacuously passing test. The rewind assertion remains meaningful regardless of which code path exhausts the cursor.

What is the motivation for this change?

Release Highlight

Release notes highlight

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@tadjik1 tadjik1 marked this pull request as ready for review April 10, 2026 13:33
@tadjik1 tadjik1 requested a review from a team as a code owner April 10, 2026 13:33
Copilot AI review requested due to automatic review settings April 10, 2026 13:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR relaxes the NODE-6878 sharded regression test by removing the CursorResponse.emptyGetMore spy assertion, keeping the test focused on verifying that cursor.rewind() continues to work after the cursor is exhausted via limit.

Changes:

  • Removed the CursorResponse.emptyGetMore spy/assertion from the sharded NODE-6878 regression test.
  • Updated the test’s inline commentary to account for mongos behavior changes on MongoDB 9.0+.
Comments suppressed due to low confidence (1)

test/integration/crud/find.test.ts:1100

  • After rewinding, the test only awaits cursor.toArray() without asserting anything about the returned documents. This can allow the test to pass even if rewind() results in an incorrectly empty/partial iteration (as long as no exception is thrown). Consider asserting the expected number of documents (e.g., 3 for limit: 3) and/or their contents, and updating the test description accordingly since it no longer validates CursorResponse.emptyGetMore fields.
      cursor.rewind();

      await cursor.toArray();
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/integration/crud/find.test.ts Outdated
Comment thread test/integration/crud/find.test.ts
@dariakp dariakp self-assigned this Apr 10, 2026
@dariakp dariakp added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Apr 10, 2026
@dariakp
Copy link
Copy Markdown
Contributor

dariakp commented Apr 13, 2026

@tadjik1 There are two failing tests still, do we have known tracking for either of them? The bson tests seem to be running an earlier version of the test - could you check on that?

@tadjik1 tadjik1 merged commit 1fc0e09 into main Apr 14, 2026
30 of 32 checks passed
@tadjik1 tadjik1 deleted the NODE-7513 branch April 14, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Primary Review In Review with primary reviewer, not yet ready for team's eyes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants