File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ export interface AbstractCursorOptions extends BSONSerializeOptions {
111
111
noCursorTimeout ?: boolean ;
112
112
/** @internal TODO(NODE-5688): make this public */
113
113
timeoutMS ?: number ;
114
+ timeoutMode ?: CursorTimeoutMode ;
114
115
}
115
116
116
117
/** @internal */
@@ -189,6 +190,26 @@ export abstract class AbstractCursor<
189
190
...pluckBSONSerializeOptions ( options )
190
191
} ;
191
192
this . cursorOptions . timeoutMS = options . timeoutMS ;
193
+ if ( this . cursorOptions . timeoutMS != null ) {
194
+ this . cursorOptions . timeoutMode = options . timeoutMode ;
195
+ }
196
+
197
+ if ( this . cursorOptions . timeoutMS != null ) {
198
+ if ( this . cursorOptions . timeoutMode == null ) {
199
+ if ( this . cursorOptions . tailable ) {
200
+ this . cursorOptions . timeoutMode = CursorTimeoutMode . ITERATION ;
201
+ } else {
202
+ this . cursorOptions . timeoutMode = CursorTimeoutMode . LIFETIME ;
203
+ }
204
+ } else {
205
+ if (
206
+ this . cursorOptions . tailable &&
207
+ this . cursorOptions . timeoutMode === CursorTimeoutMode . LIFETIME
208
+ ) {
209
+ throw new MongoAPIError ( "Cannot set tailable cursor's timeoutMode to LIFETIME" ) ;
210
+ }
211
+ }
212
+ }
192
213
193
214
const readConcern = ReadConcern . fromOptions ( options ) ;
194
215
if ( readConcern ) {
You can’t perform that action at this time.
0 commit comments