File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export class Timeout extends Promise<never> {
4141 public timedOut = false ;
4242
4343 /** Create a new timeout that expires in `duration` ms */
44- private constructor ( executor : Executor = ( ) => null , duration : number ) {
44+ private constructor ( executor : Executor = ( ) => null , duration : number , unref = false ) {
4545 let reject ! : Reject ;
4646
4747 if ( duration < 0 ) {
@@ -63,8 +63,8 @@ export class Timeout extends Promise<never> {
6363 this . timedOut = true ;
6464 reject ( new TimeoutError ( `Expired after ${ duration } ms` ) ) ;
6565 } , this . duration ) ;
66- // Ensure we do not keep the Node.js event loop running
67- if ( typeof this . id . unref === 'function' ) {
66+ if ( typeof this . id . unref === 'function' && unref ) {
67+ // Ensure we do not keep the Node.js event loop running
6868 this . id . unref ( ) ;
6969 }
7070 }
@@ -78,8 +78,8 @@ export class Timeout extends Promise<never> {
7878 this . id = undefined ;
7979 }
8080
81- public static expires ( durationMS : number ) : Timeout {
82- return new Timeout ( undefined , durationMS ) ;
81+ public static expires ( durationMS : number , unref ?: boolean ) : Timeout {
82+ return new Timeout ( undefined , durationMS , unref ) ;
8383 }
8484
8585 static is ( timeout : unknown ) : timeout is Timeout {
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ describe('Timeout', function () {
2323 beforeEach ( ( ) => {
2424 timeout = Timeout . expires ( 2000 ) ;
2525 } ) ;
26- it ( 'creates a timeout instance that will not keep the Node.js event loop active' , function ( ) {
26+ it . skip ( 'creates a timeout instance that will not keep the Node.js event loop active' , function ( ) {
2727 expect ( timeout ) . to . have . property ( 'id' ) ;
2828 // @ts -expect-error: accessing private property
2929 const id = timeout . id ;
3030 expect ( id ?. hasRef ( ) ) . to . be . false ;
31- } ) ;
31+ } ) . skipReason = 'Skipping until further work during CSOT implementation' ;
3232 it ( 'throws a TimeoutError when it expires' , async function ( ) {
3333 try {
3434 await timeout ;
You can’t perform that action at this time.
0 commit comments