Skip to content

GODRIVER-3473 Short-cicruit cursor.next() on invalid timeouts #2135

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

prestonvasquez
Copy link
Member

@prestonvasquez prestonvasquez commented Jul 22, 2025

GODRIVER-3473

Summary

Short-circuit calls to cursor.Next() where maxAwaitTimeMS >= operation timeout, which would result in socket timeouts.

Background & Motivation

The specifications assume that drivers iteratively apply the timeout provided at the constructor level (e.g., (*collection).Find) for tailable awaitData cursors:

If set, drivers MUST apply the timeoutMS option to the initial aggregate operation. Drivers MUST also apply the original timeoutMS value to each next call on the change stream but MUST NOT use it to derive a maxTimeMS field for getMore commands.

The Go Driver might decide to support the above behavior with DRIVERS-2722. The principal concern is that it would be unexpected for users to apply an operation-level timeout via contexts to a constructor and then have that timeout later be applied while working with a resulting cursor. Instead, it is more idiomatic to apply the timeout to the context passed to Next or TryNext.

@mongodb-drivers-pr-bot mongodb-drivers-pr-bot bot added the priority-3-low Low Priority PR for Review label Jul 22, 2025
Copy link
Contributor

mongodb-drivers-pr-bot bot commented Jul 22, 2025

API Change Report

./v2/x/mongo/driver

compatible changes

(*BatchCursor).MaxAwaitTime: added

@prestonvasquez prestonvasquez marked this pull request as ready for review July 23, 2025 17:27
@prestonvasquez prestonvasquez requested a review from a team as a code owner July 23, 2025 17:27
@prestonvasquez prestonvasquez requested review from qingyang-hu and matthewdale and removed request for qingyang-hu July 23, 2025 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-3-low Low Priority PR for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant