@@ -1674,22 +1674,30 @@ describe('ChangeStream resumability', function () {
1674
1674
} ;
1675
1675
1676
1676
const resumableErrorCodes = [
1677
- { error : 'HostUnreachable' , code : 6 } ,
1678
- { error : 'HostNotFound' , code : 7 } ,
1679
- { error : 'NetworkTimeout' , code : 89 } ,
1680
- { error : 'ShutdownInProgress' , code : 91 } ,
1681
- { error : 'PrimarySteppedDown' , code : 189 } ,
1682
- { error : 'ExceededTimeLimit' , code : 262 } ,
1683
- { error : 'SocketException' , code : 9001 } ,
1684
- { error : 'NotWritablePrimary' , code : 10107 } ,
1685
- { error : 'InterruptedAtShutdown' , code : 11600 } ,
1686
- { error : 'InterruptedDueToReplStateChange' , code : 11602 } ,
1687
- { error : 'NotPrimaryNoSecondaryOk' , code : 13435 } ,
1688
- { error : 'StaleShardVersion' , code : 63 } ,
1689
- { error : 'StaleEpoch' , code : 150 } ,
1690
- { error : 'RetryChangeStream' , code : 234 } ,
1691
- { error : 'FailedToSatisfyReadPreference' , code : 133 } ,
1692
- { error : 'CursorNotFound' , code : 43 }
1677
+ { error : 'HostUnreachable' , code : 6 , message : 'host unreachable' } ,
1678
+ { error : 'HostNotFound' , code : 7 , message : 'hot not found' } ,
1679
+ { error : 'NetworkTimeout' , code : 89 , message : 'network timeout' } ,
1680
+ { error : 'ShutdownInProgress' , code : 91 , message : 'shutdown in progress' } ,
1681
+ { error : 'PrimarySteppedDown' , code : 189 , message : 'primary stepped down' } ,
1682
+ { error : 'ExceededTimeLimit' , code : 262 , message : 'operation exceeded time limit' } ,
1683
+ { error : 'SocketException' , code : 9001 , message : 'socket exception' } ,
1684
+ { error : 'NotWritablePrimary' , code : 10107 , message : 'not writable primary' } ,
1685
+ { error : 'InterruptedAtShutdown' , code : 11600 , message : 'interrupted at shutdown' } ,
1686
+ {
1687
+ error : 'InterruptedDueToReplStateChange' ,
1688
+ code : 11602 ,
1689
+ message : 'interrupted due to state change'
1690
+ } ,
1691
+ { error : 'NotPrimaryNoSecondaryOk' , code : 13435 , message : 'not primary and no secondary ok' } ,
1692
+ { error : 'StaleShardVersion' , code : 63 , message : 'stale shard version' } ,
1693
+ { error : 'StaleEpoch' , code : 150 , message : 'stale epoch' } ,
1694
+ { error : 'RetryChangeStream' , code : 234 , message : 'retry change stream' } ,
1695
+ {
1696
+ error : 'FailedToSatisfyReadPreference' ,
1697
+ code : 133 ,
1698
+ message : 'failed to satisfy read preference'
1699
+ } ,
1700
+ { error : 'CursorNotFound' , code : 43 , message : 'cursor not found' }
1693
1701
] ;
1694
1702
1695
1703
const is4_2Server = ( serverVersion : string ) =>
@@ -1731,7 +1739,7 @@ describe('ChangeStream resumability', function () {
1731
1739
1732
1740
context ( 'iterator api' , function ( ) {
1733
1741
context ( '#next' , function ( ) {
1734
- for ( const { error, code } of resumableErrorCodes ) {
1742
+ for ( const { error, code, message } of resumableErrorCodes ) {
1735
1743
it (
1736
1744
`resumes on error code ${ code } (${ error } )` ,
1737
1745
{ requires : { topology : '!single' , mongodb : '>=4.2' } } ,
@@ -1746,7 +1754,8 @@ describe('ChangeStream resumability', function () {
1746
1754
mode : { times : 1 } ,
1747
1755
data : {
1748
1756
failCommands : [ 'getMore' ] ,
1749
- errorCode : code
1757
+ errorCode : code ,
1758
+ errmsg : message
1750
1759
}
1751
1760
} as FailPoint ) ;
1752
1761
@@ -1759,7 +1768,7 @@ describe('ChangeStream resumability', function () {
1759
1768
}
1760
1769
) ;
1761
1770
}
1762
- for ( const { error, code } of resumableErrorCodes ) {
1771
+ for ( const { error, code, message } of resumableErrorCodes ) {
1763
1772
it (
1764
1773
`resumes on error code ${ code } (${ error } )` ,
1765
1774
{ requires : { topology : '!single' , mongodb : '<4.2' } } ,
@@ -1778,7 +1787,7 @@ describe('ChangeStream resumability', function () {
1778
1787
. stub ( changeStream . cursor , '_getMore' )
1779
1788
. callsFake ( ( _batchSize , callback ) => {
1780
1789
mock . restore ( ) ;
1781
- const error = new MongoServerError ( { message : 'Something went wrong' } ) ;
1790
+ const error = new MongoServerError ( { message : message } ) ;
1782
1791
error . code = code ;
1783
1792
callback ( error ) ;
1784
1793
} ) ;
@@ -1807,7 +1816,8 @@ describe('ChangeStream resumability', function () {
1807
1816
mode : { times : 1 } ,
1808
1817
data : {
1809
1818
failCommands : [ 'getMore' ] ,
1810
- errorCode : resumableErrorCodes [ 0 ] . code
1819
+ errorCode : resumableErrorCodes [ 0 ] . code ,
1820
+ errmsg : resumableErrorCodes [ 0 ] . message
1811
1821
}
1812
1822
} as FailPoint ) ;
1813
1823
@@ -1858,7 +1868,7 @@ describe('ChangeStream resumability', function () {
1858
1868
} ) ;
1859
1869
1860
1870
context ( '#hasNext' , function ( ) {
1861
- for ( const { error, code } of resumableErrorCodes ) {
1871
+ for ( const { error, code, message } of resumableErrorCodes ) {
1862
1872
it (
1863
1873
`resumes on error code ${ code } (${ error } )` ,
1864
1874
{ requires : { topology : '!single' , mongodb : '>=4.2' } } ,
@@ -1873,7 +1883,8 @@ describe('ChangeStream resumability', function () {
1873
1883
mode : { times : 1 } ,
1874
1884
data : {
1875
1885
failCommands : [ 'getMore' ] ,
1876
- errorCode : code
1886
+ errorCode : code ,
1887
+ errmsg : message
1877
1888
}
1878
1889
} as FailPoint ) ;
1879
1890
@@ -1887,7 +1898,7 @@ describe('ChangeStream resumability', function () {
1887
1898
) ;
1888
1899
}
1889
1900
1890
- for ( const { error, code } of resumableErrorCodes ) {
1901
+ for ( const { error, code, message } of resumableErrorCodes ) {
1891
1902
it (
1892
1903
`resumes on error code ${ code } (${ error } )` ,
1893
1904
{ requires : { topology : '!single' , mongodb : '<4.2' } } ,
@@ -1906,7 +1917,7 @@ describe('ChangeStream resumability', function () {
1906
1917
. stub ( changeStream . cursor , '_getMore' )
1907
1918
. callsFake ( ( _batchSize , callback ) => {
1908
1919
mock . restore ( ) ;
1909
- const error = new MongoServerError ( { message : 'Something went wrong' } ) ;
1920
+ const error = new MongoServerError ( { message : message } ) ;
1910
1921
error . code = code ;
1911
1922
callback ( error ) ;
1912
1923
} ) ;
@@ -1935,7 +1946,8 @@ describe('ChangeStream resumability', function () {
1935
1946
mode : { times : 1 } ,
1936
1947
data : {
1937
1948
failCommands : [ 'getMore' ] ,
1938
- errorCode : resumableErrorCodes [ 0 ] . code
1949
+ errorCode : resumableErrorCodes [ 0 ] . code ,
1950
+ errmsg : resumableErrorCodes [ 0 ] . message
1939
1951
}
1940
1952
} as FailPoint ) ;
1941
1953
@@ -1986,7 +1998,7 @@ describe('ChangeStream resumability', function () {
1986
1998
} ) ;
1987
1999
1988
2000
context ( '#tryNext' , function ( ) {
1989
- for ( const { error, code } of resumableErrorCodes ) {
2001
+ for ( const { error, code, message } of resumableErrorCodes ) {
1990
2002
it (
1991
2003
`resumes on error code ${ code } (${ error } )` ,
1992
2004
{ requires : { topology : '!single' , mongodb : '>=4.2' } } ,
@@ -2001,7 +2013,8 @@ describe('ChangeStream resumability', function () {
2001
2013
mode : { times : 1 } ,
2002
2014
data : {
2003
2015
failCommands : [ 'getMore' ] ,
2004
- errorCode : code
2016
+ errorCode : code ,
2017
+ errmsg : message
2005
2018
}
2006
2019
} as FailPoint ) ;
2007
2020
@@ -2022,7 +2035,7 @@ describe('ChangeStream resumability', function () {
2022
2035
) ;
2023
2036
}
2024
2037
2025
- for ( const { error, code } of resumableErrorCodes ) {
2038
+ for ( const { error, code, message } of resumableErrorCodes ) {
2026
2039
it (
2027
2040
`resumes on error code ${ code } (${ error } )` ,
2028
2041
{ requires : { topology : '!single' , mongodb : '<4.2' } } ,
@@ -2041,7 +2054,7 @@ describe('ChangeStream resumability', function () {
2041
2054
. stub ( changeStream . cursor , '_getMore' )
2042
2055
. callsFake ( ( _batchSize , callback ) => {
2043
2056
mock . restore ( ) ;
2044
- const error = new MongoServerError ( { message : 'Something went wrong' } ) ;
2057
+ const error = new MongoServerError ( { message : message } ) ;
2045
2058
error . code = code ;
2046
2059
callback ( error ) ;
2047
2060
} ) ;
@@ -2077,7 +2090,8 @@ describe('ChangeStream resumability', function () {
2077
2090
mode : { times : 1 } ,
2078
2091
data : {
2079
2092
failCommands : [ 'getMore' ] ,
2080
- errorCode : resumableErrorCodes [ 0 ] . code
2093
+ errorCode : resumableErrorCodes [ 0 ] . code ,
2094
+ errmsg : resumableErrorCodes [ 0 ] . message
2081
2095
}
2082
2096
} as FailPoint ) ;
2083
2097
@@ -2127,7 +2141,7 @@ describe('ChangeStream resumability', function () {
2127
2141
} ) ;
2128
2142
2129
2143
describe ( 'event emitter based iteration' , function ( ) {
2130
- for ( const { error, code } of resumableErrorCodes ) {
2144
+ for ( const { error, code, message } of resumableErrorCodes ) {
2131
2145
it (
2132
2146
`resumes on error code ${ code } (${ error } )` ,
2133
2147
{ requires : { topology : '!single' , mongodb : '>=4.2' } } ,
@@ -2141,7 +2155,8 @@ describe('ChangeStream resumability', function () {
2141
2155
mode : { times : 1 } ,
2142
2156
data : {
2143
2157
failCommands : [ 'getMore' ] ,
2144
- errorCode : code
2158
+ errorCode : code ,
2159
+ errmsg : message
2145
2160
}
2146
2161
} as FailPoint ) ;
2147
2162
@@ -2171,7 +2186,8 @@ describe('ChangeStream resumability', function () {
2171
2186
mode : { times : 1 } ,
2172
2187
data : {
2173
2188
failCommands : [ 'getMore' ] ,
2174
- errorCode : resumableErrorCodes [ 0 ] . code
2189
+ errorCode : resumableErrorCodes [ 0 ] . code ,
2190
+ errmsg : resumableErrorCodes [ 0 ] . message
2175
2191
}
2176
2192
} as FailPoint ) ;
2177
2193
@@ -2222,6 +2238,38 @@ describe('ChangeStream resumability', function () {
2222
2238
}
2223
2239
) ;
2224
2240
} ) ;
2241
+
2242
+ context ( 'when the error is operation was interrupted' , function ( ) {
2243
+ it (
2244
+ 'does not resume' ,
2245
+ { requires : { topology : '!single' , mongodb : '>=4.2' } } ,
2246
+ async function ( ) {
2247
+ changeStream = collection . watch ( [ ] ) ;
2248
+
2249
+ const unresumableErrorCode = 237 ;
2250
+ await client . db ( 'admin' ) . command ( {
2251
+ configureFailPoint : is4_2Server ( this . configuration . version )
2252
+ ? 'failCommand'
2253
+ : 'failGetMoreAfterCursorCheckout' ,
2254
+ mode : { times : 1 } ,
2255
+ data : {
2256
+ failCommands : [ 'getMore' ] ,
2257
+ errorCode : unresumableErrorCode ,
2258
+ errmsg : 'operation was interrupted'
2259
+ }
2260
+ } as FailPoint ) ;
2261
+
2262
+ const willBeError = once ( changeStream , 'change' ) . catch ( error => error ) ;
2263
+ await once ( changeStream . cursor , 'init' ) ;
2264
+ await collection . insertOne ( { name : 'bailey' } ) ;
2265
+
2266
+ const error = await willBeError ;
2267
+
2268
+ expect ( error ) . to . be . instanceOf ( MongoServerError ) ;
2269
+ expect ( aggregateEvents ) . to . have . lengthOf ( 1 ) ;
2270
+ }
2271
+ ) ;
2272
+ } ) ;
2225
2273
} ) ;
2226
2274
2227
2275
it (
0 commit comments