@@ -1359,49 +1359,62 @@ describe('CSOT driver tests', metadata, () => {
1359
1359
} ) ;
1360
1360
} ) ;
1361
1361
1362
- describe ( 'Connection after timeout' , { requires : { mongodb : '>=4.4' } } , function ( ) {
1363
- let client : MongoClient ;
1364
-
1365
- beforeEach ( async function ( ) {
1366
- client = this . configuration . newClient ( { timeoutMS : 500 } ) ;
1367
-
1368
- const failpoint : FailPoint = {
1369
- configureFailPoint : 'failCommand' ,
1370
- mode : {
1371
- times : 1
1372
- } ,
1373
- data : {
1374
- failCommands : [ 'insert' ] ,
1375
- blockConnection : true ,
1376
- blockTimeMS : 700
1377
- }
1378
- } ;
1379
-
1380
- await client . db ( 'admin' ) . command ( failpoint ) ;
1381
- } ) ;
1362
+ // TODO(NODE-7118): Find a way to reimplement this test for latest server.
1363
+ describe (
1364
+ 'Connection after timeout' ,
1365
+ {
1366
+ requires : {
1367
+ // 4.4 for use of failCommands
1368
+ // < 8.3 because of https://jira.mongodb.org/browse/SERVER-101116
1369
+ mongodb : '>=4.4 <=8.2'
1370
+ }
1371
+ } ,
1372
+ function ( ) {
1373
+ let client : MongoClient ;
1382
1374
1383
- afterEach ( async function ( ) {
1384
- await client . close ( ) ;
1385
- } ) ;
1375
+ beforeEach ( async function ( ) {
1376
+ client = this . configuration . newClient ( { timeoutMS : 500 } ) ;
1386
1377
1387
- it ( 'closes so pending messages are not read by another operation' , async function ( ) {
1388
- const cmap = [ ] ;
1389
- client . on ( 'connectionCheckedOut' , ev => cmap . push ( ev ) ) ;
1390
- client . on ( 'connectionClosed' , ev => cmap . push ( ev ) ) ;
1378
+ const failpoint : FailPoint = {
1379
+ configureFailPoint : 'failCommand' ,
1380
+ mode : {
1381
+ times : 1
1382
+ } ,
1383
+ data : {
1384
+ failCommands : [ 'insert' ] ,
1385
+ blockConnection : true ,
1386
+ blockTimeMS : 700
1387
+ }
1388
+ } ;
1391
1389
1392
- const error = await client
1393
- . db ( 'socket' )
1394
- . collection ( 'closes' )
1395
- . insertOne ( { } )
1396
- . catch ( error => error ) ;
1390
+ await client . db ( 'admin' ) . command ( failpoint ) ;
1391
+ } ) ;
1397
1392
1398
- expect ( error ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
1399
- expect ( cmap ) . to . have . lengthOf ( 2 ) ;
1393
+ afterEach ( async function ( ) {
1394
+ await client . close ( ) ;
1395
+ } ) ;
1400
1396
1401
- const [ checkedOut , closed ] = cmap ;
1402
- expect ( checkedOut ) . to . have . property ( 'name' , 'connectionCheckedOut' ) ;
1403
- expect ( closed ) . to . have . property ( 'name' , 'connectionClosed' ) ;
1404
- expect ( checkedOut ) . to . have . property ( 'connectionId' , closed . connectionId ) ;
1405
- } ) ;
1406
- } ) ;
1397
+ it ( 'closes so pending messages are not read by another operation' , async function ( ) {
1398
+ const cmap = [ ] ;
1399
+ client . on ( 'connectionCheckedOut' , ev => cmap . push ( ev ) ) ;
1400
+ client . on ( 'connectionClosed' , ev => cmap . push ( ev ) ) ;
1401
+
1402
+ const error = await client
1403
+ . db ( 'socket' )
1404
+ . collection ( 'closes' )
1405
+ . insertOne ( { } )
1406
+ . catch ( error => error ) ;
1407
+
1408
+ // Note: In the case where the timeout comes from the server, the driver does not
1409
+ // need to close the connection as no more potential messages are expected.
1410
+ expect ( error ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
1411
+ expect ( cmap ) . to . have . lengthOf ( 2 ) ;
1412
+
1413
+ const [ checkedOut , closed ] = cmap ;
1414
+ expect ( checkedOut ) . to . have . property ( 'name' , 'connectionCheckedOut' ) ;
1415
+ expect ( closed ) . to . have . property ( 'name' , 'connectionClosed' ) ;
1416
+ expect ( checkedOut ) . to . have . property ( 'connectionId' , closed . connectionId ) ;
1417
+ } ) ;
1418
+ }
1419
+ ) ;
1407
1420
} ) ;
0 commit comments