Skip to content

Commit dc35fae

Browse files
fixup! Extend mongo.batchCursor with MaxAwaitTime for validation
1 parent 0b15e7f commit dc35fae

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mongo/cursor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ func (c *Cursor) next(ctx context.Context, nonBlocking bool) bool {
195195
// operation-level timeout via contexts to a constructor and then that timeout
196196
// later be applied while working with a resulting cursor. Instead, it is more
197197
// idiomatic to apply the timeout to the context passed to Next or TryNext.
198-
if !nonBlocking && !mongoutil.TimeoutWithinContext(ctx, c.bc.MaxAwaitTime()) {
198+
maxAwaitTime := c.bc.MaxAwaitTime() //
199+
if maxAwaitTime != nil && !nonBlocking && !mongoutil.TimeoutWithinContext(ctx, *maxAwaitTime) {
199200
c.err = fmt.Errorf("MaxAwaitTime must be less than the operation timeout")
200201

201202
return false

0 commit comments

Comments
 (0)