Skip to content

feat(NODE-6472): findOne and find no longer keep open cursors #4580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Aug 1, 2025

Conversation

durran
Copy link
Member

@durran durran commented Jul 9, 2025

Description

Changes findOne to set options that will not require a cursor or a killCursors command. Updates find to not leave cursors open on the server when batch size and limit are equal.

What is changing?

  • The find one operation now deprecates options for it specifically which are irrelevant.
  • The find operation now sets batchSize to batchSize + 1 when the limit is equal to it.
  • Syncs CRUD spec tests.
Is there new documentation needed for these changes?

API docs on the findOne options.

What is the motivation for this change?

NODE-6472

Release Highlight

collection.findOne() and collection.find() will no longer potentially leave open cursors on the server

The findOne command will now always set the limit option to 1 and singleBatch to true. The limit, noCursorResponse and batchSize options have also been deprecated, and the command will guarantee no more cursors can be orphaned and no killCursors command will be potentially executed.

find will now set limit to batchSize + 1 when both options were equal, to avoid leaving cursors open.

Double check the following

  • Ran npm run check:lint script
  • 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

@durran durran force-pushed the NODE-6472 branch 4 times, most recently from 11b1cf5 to 9fe1c2d Compare July 11, 2025 16:24
@durran durran changed the title feat(NODE-6472): run findOne without cursor feat(NODE-6472): findOne and find no longer keep open cursors Jul 22, 2025
@durran durran marked this pull request as ready for review July 22, 2025 22:25
@durran durran requested a review from a team as a code owner July 22, 2025 22:25
@baileympearson baileympearson self-assigned this Jul 23, 2025
@baileympearson baileympearson added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jul 23, 2025
@durran durran requested a review from baileympearson July 24, 2025 10:42
@durran durran force-pushed the NODE-6472 branch 3 times, most recently from feaeb6b to 5ba6dfe Compare August 1, 2025 09:35
@baileympearson baileympearson requested a review from dariakp August 1, 2025 15:53
@baileympearson baileympearson added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Aug 1, 2025
@baileympearson baileympearson merged commit be7f808 into main Aug 1, 2025
31 checks passed
@baileympearson baileympearson deleted the NODE-6472 branch August 1, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants