Skip to content

Commit d953475

Browse files
committed
fix(NODE-4475): make interrupted message more specific
1 parent ca51fec commit d953475

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/cursor/abstract_cursor.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -895,14 +895,22 @@ class ReadableCursorStream extends Readable {
895895
}
896896

897897
// NOTE: This is also perhaps questionable. The rationale here is that these errors tend
898-
// to be "operation interrupted", where a cursor has been closed but there is an
898+
// to be "operation was interrupted", where a cursor has been closed but there is an
899899
// active getMore in-flight. This used to check if the cursor was killed but once
900900
// that changed to happen in cleanup legitimate errors would not destroy the
901901
// stream. There are change streams test specifically test these cases.
902-
if (err.message.match(/interrupted/)) {
902+
if (err.message.match(/operation was interrupted/)) {
903903
return this.push(null);
904904
}
905905

906+
// NOTE: The two above checks on the message of the error will cause a null to be pushed
907+
// to the stream, thus closing the stream before the destroy call happens. This means
908+
// that either of those error messages on a change stream will not get a proper
909+
// 'error' event to be emitted (the error passed to destroy). Change stream resumability
910+
// relies on that error event to be emitted to create its new cursor and thus was not
911+
// working on 4.4 servers because the error emitted on failover was "interrupted at
912+
// shutdown" while on 5.0+ it is "The server is in quiesce mode and will shut down".
913+
// See NODE-4475.
906914
return this.destroy(err);
907915
}
908916

0 commit comments

Comments
 (0)