@@ -14,6 +14,7 @@ import {
14
14
type CommandStartedEvent ,
15
15
type Db ,
16
16
isHello ,
17
+ LEGACY_HELLO_COMMAND ,
17
18
Long ,
18
19
MongoAPIError ,
19
20
MongoChangeStreamError ,
@@ -1818,7 +1819,7 @@ describe('Change Streams', function () {
1818
1819
} ) ;
1819
1820
} ) ;
1820
1821
1821
- describe ( 'ChangeStream resumability' , function ( ) {
1822
+ describe . only ( 'ChangeStream resumability' , function ( ) {
1822
1823
let client : MongoClient ;
1823
1824
let collection : Collection ;
1824
1825
let changeStream : ChangeStream ;
@@ -2045,6 +2046,65 @@ describe('ChangeStream resumability', function () {
2045
2046
expect ( changeStream . closed ) . to . be . true ;
2046
2047
} ) ;
2047
2048
} ) ;
2049
+
2050
+ context . only ( 'when the error is not a server error' , function ( ) {
2051
+ let client1 : MongoClient ;
2052
+ let client2 : MongoClient ;
2053
+
2054
+ beforeEach ( async function ( ) {
2055
+ client1 = this . configuration . newClient (
2056
+ { } ,
2057
+ { serverSelectionTimeoutMS : 1000 , appName : 'client-errors' }
2058
+ ) ;
2059
+ client2 = this . configuration . newClient ( ) ;
2060
+
2061
+ collection = client1 . db ( 'client-errors' ) . collection ( 'test' ) ;
2062
+ } ) ;
2063
+
2064
+ afterEach ( async function ( ) {
2065
+ await client2 . db ( 'admin' ) . command ( {
2066
+ configureFailPoint : 'failCommand' ,
2067
+ mode : 'off' ,
2068
+ data : { appName : 'client-errors' }
2069
+ } as FailCommandFailPoint ) ;
2070
+
2071
+ await client1 ?. close ( ) ;
2072
+ await client2 ?. close ( ) ;
2073
+ } ) ;
2074
+
2075
+ it (
2076
+ 'should resume on ServerSelectionError' ,
2077
+ { requires : { topology : '!single' } } ,
2078
+ async function ( ) {
2079
+ changeStream = collection . watch ( [ ] ) ;
2080
+ await initIteratorMode ( changeStream ) ;
2081
+
2082
+ await collection . insertOne ( { a : 1 } ) ;
2083
+
2084
+ await client2 . db ( 'admin' ) . command ( {
2085
+ configureFailPoint : 'failCommand' ,
2086
+ mode : 'alwaysOn' ,
2087
+ data : {
2088
+ failCommands : [ 'ping' , 'hello' , LEGACY_HELLO_COMMAND ] ,
2089
+ closeConnection : true ,
2090
+ handshakeCommands : true ,
2091
+ failInternalCommands : true ,
2092
+ appName : 'client-errors'
2093
+ }
2094
+ } as FailCommandFailPoint ) ;
2095
+ await client2
2096
+ . db ( 'admin' )
2097
+ . command ( { replSetFreeze : 0 } , { readPreference : ReadPreference . secondary } ) ;
2098
+ await client2
2099
+ . db ( 'admin' )
2100
+ . command ( { replSetStepDown : 15 , secondaryCatchUpPeriodSecs : 10 , force : true } ) ;
2101
+ // await sleep(15_000);
2102
+
2103
+ const change = await changeStream . next ( ) ;
2104
+ expect ( change ) . to . containSubset ( { operationType : 'insert' , fullDocument : { a : 1 } } ) ;
2105
+ }
2106
+ ) ;
2107
+ } ) ;
2048
2108
} ) ;
2049
2109
2050
2110
context ( '#hasNext' , function ( ) {
0 commit comments