File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff 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 ( / i n t e r r u p t e d / ) ) {
902+ if ( err . message . match ( / o p e r a t i o n w a s i n t e r r u p t e d / ) ) {
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
You can’t perform that action at this time.
0 commit comments