@internal
(changeStreamError: AnyError, cursorInitialized: boolean)
| 1042 | |
| 1043 | /** @internal */ |
| 1044 | private async _processErrorIteratorMode(changeStreamError: AnyError, cursorInitialized: boolean) { |
| 1045 | if (this.isClosed) { |
| 1046 | // TODO(NODE-3485): Replace with MongoChangeStreamClosedError |
| 1047 | throw new MongoAPIError(CHANGESTREAM_CLOSED_ERROR); |
| 1048 | } |
| 1049 | |
| 1050 | if ( |
| 1051 | cursorInitialized && |
| 1052 | (isResumableError(changeStreamError, this.cursor.maxWireVersion) || |
| 1053 | changeStreamError instanceof MongoOperationTimeoutError) |
| 1054 | ) { |
| 1055 | try { |
| 1056 | await this.cursor.close(); |
| 1057 | } catch (error) { |
| 1058 | squashError(error); |
| 1059 | } |
| 1060 | |
| 1061 | await this._resume(changeStreamError); |
| 1062 | |
| 1063 | if (changeStreamError instanceof MongoOperationTimeoutError) throw changeStreamError; |
| 1064 | } else { |
| 1065 | try { |
| 1066 | await this.close(); |
| 1067 | } catch (error) { |
| 1068 | squashError(error); |
| 1069 | } |
| 1070 | |
| 1071 | throw changeStreamError; |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | private async _resume(changeStreamError: AnyError) { |
| 1076 | this.timeoutContext?.refresh(); |
no test coverage detected