You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
1099
+
* // do nothing
1100
+
* } else {
1101
+
* changeStream.close();
1102
+
* }
1103
+
* });
1104
+
* ```
1105
+
*
1053
1106
* @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
1054
1107
* @param options - Optional settings for the command
1055
1108
* @typeParam TLocal - Type of the data being detected by the change stream
Copy file name to clipboardExpand all lines: src/db.ts
+52Lines changed: 52 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -531,6 +531,58 @@ export class Db {
531
531
* - The first is to provide the schema that may be defined for all the collections within this database
532
532
* - The second is to override the shape of the change stream document entirely, if it is not provided the type will default to ChangeStreamDocument of the first argument
533
533
*
534
+
* @remarks
535
+
* When `timeoutMS` is configured for a change stream, it will have different behaviour depending
536
+
* on whether the change stream is in iterator mode or emitter mode. In both cases, a change
537
+
* stream will time out if it does not receive a change event within `timeoutMS` of the last change
538
+
* event.
539
+
*
540
+
* Note that if a change stream is consistently timing out when watching a collection, database or
541
+
* client that is being changed, then this may be due to the server timing out before it can finish
542
+
* processing the existing oplog. To address this, restart the change stream with a higher
543
+
* `timeoutMS`.
544
+
*
545
+
* If the change stream times out the initial aggregate operation to establish the change stream on
546
+
* the server, then the client will close the change stream. If the getMore calls to the server
547
+
* time out, then the change stream will be left open, but will throw a MongoOperationTimeoutError
548
+
* when in iterator mode and emit an error event that returns a MongoOperationTimeoutError in
549
+
* emitter mode.
550
+
*
551
+
* To determine whether or not the change stream is still open following a timeout, check the
552
+
* {@link ChangeStream.closed} getter.
553
+
*
554
+
* @example
555
+
* In iterator mode, if a next() call throws a timeout error, it will attempt to resume the change stream.
556
+
* The next call can just be retried after this succeeds.
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
580
+
* // do nothing
581
+
* } else {
582
+
* changeStream.close();
583
+
* }
584
+
* });
585
+
* ```
534
586
* @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
535
587
* @param options - Optional settings for the command
536
588
* @typeParam TSchema - Type of the data being detected by the change stream
Copy file name to clipboardExpand all lines: src/mongo_client.ts
+52Lines changed: 52 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -814,6 +814,58 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
814
814
* - The first is to provide the schema that may be defined for all the data within the current cluster
815
815
* - The second is to override the shape of the change stream document entirely, if it is not provided the type will default to ChangeStreamDocument of the first argument
816
816
*
817
+
* @remarks
818
+
* When `timeoutMS` is configured for a change stream, it will have different behaviour depending
819
+
* on whether the change stream is in iterator mode or emitter mode. In both cases, a change
820
+
* stream will time out if it does not receive a change event within `timeoutMS` of the last change
821
+
* event.
822
+
*
823
+
* Note that if a change stream is consistently timing out when watching a collection, database or
824
+
* client that is being changed, then this may be due to the server timing out before it can finish
825
+
* processing the existing oplog. To address this, restart the change stream with a higher
826
+
* `timeoutMS`.
827
+
*
828
+
* If the change stream times out the initial aggregate operation to establish the change stream on
829
+
* the server, then the client will close the change stream. If the getMore calls to the server
830
+
* time out, then the change stream will be left open, but will throw a MongoOperationTimeoutError
831
+
* when in iterator mode and emit an error event that returns a MongoOperationTimeoutError in
832
+
* emitter mode.
833
+
*
834
+
* To determine whether or not the change stream is still open following a timeout, check the
835
+
* {@link ChangeStream.closed} getter.
836
+
*
837
+
* @example
838
+
* In iterator mode, if a next() call throws a timeout error, it will attempt to resume the change stream.
839
+
* The next call can just be retried after this succeeds.
* if (e instanceof MongoOperationTimeoutError && !changeStream.closed) {
863
+
* // do nothing
864
+
* } else {
865
+
* changeStream.close();
866
+
* }
867
+
* });
868
+
* ```
817
869
* @param pipeline - An array of {@link https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents. This allows for filtering (using $match) and manipulating the change stream documents.
818
870
* @param options - Optional settings for the command
819
871
* @typeParam TSchema - Type of the data being detected by the change stream
0 commit comments