MCPcopy
hub / github.com/mongodb/node-mongodb-native / _processChange

Method _processChange

src/change_stream.ts:984–1008  ·  view source on GitHub ↗

@internal

(change: TChange | null)

Source from the content-addressed store, hash-verified

982
983 /** @internal */
984 private _processChange(change: TChange | null): TChange {
985 if (this.isClosed) {
986 // TODO(NODE-3485): Replace with MongoChangeStreamClosedError
987 throw new MongoAPIError(CHANGESTREAM_CLOSED_ERROR);
988 }
989
990 // a null change means the cursor has been notified, implicitly closing the change stream
991 if (change == null) {
992 // TODO(NODE-3485): Replace with MongoChangeStreamClosedError
993 throw new MongoRuntimeError(CHANGESTREAM_CLOSED_ERROR);
994 }
995
996 if (change && !change._id) {
997 throw new MongoChangeStreamError(NO_RESUME_TOKEN_ERROR);
998 }
999
1000 // cache the resume token
1001 this.cursor.cacheResumeToken(change._id);
1002
1003 // wipe the startAtOperationTime if there was one so that there won't be a conflict
1004 // between resumeToken and startAtOperationTime if we need to reconnect the cursor
1005 this.options.startAtOperationTime = undefined;
1006
1007 return change;
1008 }
1009
1010 /** @internal */
1011 private _processErrorStreamMode(changeStreamError: AnyError, cursorInitialized: boolean) {

Callers 3

nextMethod · 0.95
tryNextMethod · 0.95
_streamEventsMethod · 0.95

Calls 1

cacheResumeTokenMethod · 0.80

Tested by

no test coverage detected