@@ -337,7 +337,7 @@ describe('AbortSignal support', () => {
337337 const start = performance . now ( ) ;
338338 const result = await willBeResult ;
339339 const end = performance . now ( ) ;
340- expect ( end - start ) . to . be . lessThan ( 1000 ) ; // should be way less than 5s server selection timeout
340+ expect ( end - start ) . to . be . lessThan ( 10 ) ; // should be way less than 5s server selection timeout
341341
342342 expect ( result ) . to . be . instanceOf ( DOMException ) ;
343343 } ) ;
@@ -387,7 +387,11 @@ describe('AbortSignal support', () => {
387387 await checkoutStartedBlocked ;
388388
389389 controller . abort ( ) ;
390+
391+ const start = performance . now ( ) ;
390392 const result = await willBeResultBlocked ;
393+ const end = performance . now ( ) ;
394+ expect ( end - start ) . to . be . lessThan ( 10 ) ;
391395
392396 expect ( result ) . to . be . instanceOf ( DOMException ) ;
393397 } ) ;
@@ -439,7 +443,10 @@ describe('AbortSignal support', () => {
439443 }
440444 }
441445
446+ const start = performance . now ( ) ;
442447 const result = await willBeResultBlocked ;
448+ const end = performance . now ( ) ;
449+ expect ( end - start ) . to . be . lessThan ( 10 ) ;
443450
444451 expect ( result ) . to . be . instanceOf ( DOMException ) ;
445452
@@ -495,7 +502,10 @@ describe('AbortSignal support', () => {
495502 client . on ( 'commandStarted' , e => e . commandName === cursorName && controller . abort ( ) ) ;
496503 const willBeResultBlocked = iterateUntilDocumentOrError ( cursor , cursorAPI , args ) ;
497504
505+ const start = performance . now ( ) ;
498506 const result = await willBeResultBlocked ;
507+ const end = performance . now ( ) ;
508+ expect ( end - start ) . to . be . lessThan ( 10 ) ; // shouldn't wait for the blocked connection
499509
500510 expect ( result ) . to . be . instanceOf ( DOMException ) ;
501511
@@ -543,7 +553,12 @@ describe('AbortSignal support', () => {
543553 . on ( 'error' , reject )
544554 . on ( 'close' , resolve ) ;
545555
546- expect ( await promise . catch ( error => error ) ) . to . be . instanceOf ( DOMException ) ;
556+ const start = performance . now ( ) ;
557+ const result = await promise . catch ( error => error ) ;
558+ const end = performance . now ( ) ;
559+ expect ( end - start ) . to . be . lessThan ( 10 ) ;
560+
561+ expect ( result ) . to . be . instanceOf ( DOMException ) ;
547562 } ) ;
548563 } ) ;
549564
@@ -784,7 +799,10 @@ describe('AbortSignal support', () => {
784799 ev => ev . commandName === 'aggregate' && sleep ( 10 ) . then ( ( ) => controller . abort ( ) )
785800 ) ;
786801
802+ const start = performance . now ( ) ;
787803 const result = await collection . countDocuments ( { } , { signal } ) . catch ( error => error ) ;
804+ const end = performance . now ( ) ;
805+ expect ( end - start ) . to . be . lessThan ( 260 ) ; // shouldn't wait for the blocked connection
788806
789807 expect ( result ) . to . be . instanceOf ( DOMException ) ;
790808 } ) ;
@@ -818,10 +836,13 @@ describe('AbortSignal support', () => {
818836 client . on (
819837 'commandStarted' ,
820838 // Abort a bit after find has started:
821- ev => ev . commandName === 'find' && sleep ( 10 ) . then ( ( ) => controller . abort ( ) )
839+ ev => ev . commandName === 'find' && sleep ( 1 ) . then ( ( ) => controller . abort ( ) )
822840 ) ;
823841
842+ const start = performance . now ( ) ;
824843 const result = await collection . findOne ( { } , { signal } ) . catch ( error => error ) ;
844+ const end = performance . now ( ) ;
845+ expect ( end - start ) . to . be . lessThan ( 10 ) ; // shouldn't wait for the blocked connection
825846
826847 expect ( result ) . to . be . instanceOf ( DOMException ) ;
827848 } ) ;
@@ -855,10 +876,13 @@ describe('AbortSignal support', () => {
855876 client . on (
856877 'commandStarted' ,
857878 // Abort a bit after ping has started:
858- ev => ev . commandName === 'ping' && sleep ( 10 ) . then ( ( ) => controller . abort ( ) )
879+ ev => ev . commandName === 'ping' && sleep ( 1 ) . then ( ( ) => controller . abort ( ) )
859880 ) ;
860881
882+ const start = performance . now ( ) ;
861883 const result = await db . command ( { ping : 1 } , { signal } ) . catch ( error => error ) ;
884+ const end = performance . now ( ) ;
885+ expect ( end - start ) . to . be . lessThan ( 10 ) ; // shouldn't wait for the blocked connection
862886
863887 expect ( result ) . to . be . instanceOf ( DOMException ) ;
864888 } ) ;
0 commit comments