@@ -4,6 +4,8 @@ import { once } from 'node:events';
4
4
import { expect } from 'chai' ;
5
5
import * as sinon from 'sinon' ;
6
6
7
+ import { sleep } from '../../tools/utils' ;
8
+
7
9
import {
8
10
Collection ,
9
11
MongoClient ,
@@ -322,9 +324,10 @@ describe('Retryable Writes Spec Prose', () => {
322
324
} ) ;
323
325
324
326
const willBeCommandSucceeded = once ( client , 'commandSucceeded' ) . catch ( error => error ) ;
325
- const willBeCommandFailed = once ( client , 'commandFailed' , {
326
- signal : AbortSignal . timeout ( 1000 )
327
- } ) . catch ( error => error ) ;
327
+ const willBeCommandFailed = Promise . race ( [
328
+ once ( client , 'commandFailed' ) ,
329
+ sleep ( 1000 ) . then ( ( ) => Promise . reject ( new Error ( 'timeout' ) ) )
330
+ ] ) . catch ( error => error ) ;
328
331
329
332
const insertResult = await collection . insertOne ( { _id : 1 } ) . catch ( error => error ) ;
330
333
@@ -335,7 +338,7 @@ describe('Retryable Writes Spec Prose', () => {
335
338
expect (
336
339
noCommandFailedEvent . message ,
337
340
'expected timeout, since no failure event should emit'
338
- ) . to . include ( 'operation was aborted ') ;
341
+ ) . to . equal ( 'timeout ') ;
339
342
expect ( insertResult ) . to . deep . equal ( { acknowledged : true , insertedId : 1 } ) ;
340
343
}
341
344
) ;
0 commit comments