@@ -4,6 +4,8 @@ import { once } from 'node:events';
44import { expect } from 'chai' ;
55import * as sinon from 'sinon' ;
66
7+ import { sleep } from '../../tools/utils' ;
8+
79import {
810 Collection ,
911 MongoClient ,
@@ -322,9 +324,10 @@ describe('Retryable Writes Spec Prose', () => {
322324 } ) ;
323325
324326 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 ) ;
328331
329332 const insertResult = await collection . insertOne ( { _id : 1 } ) . catch ( error => error ) ;
330333
@@ -335,7 +338,7 @@ describe('Retryable Writes Spec Prose', () => {
335338 expect (
336339 noCommandFailedEvent . message ,
337340 'expected timeout, since no failure event should emit'
338- ) . to . include ( 'operation was aborted ') ;
341+ ) . to . equal ( 'timeout ') ;
339342 expect ( insertResult ) . to . deep . equal ( { acknowledged : true , insertedId : 1 } ) ;
340343 }
341344 ) ;
0 commit comments