File tree 2 files changed +7
-7
lines changed
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> {
41
41
public timedOut = false ;
42
42
43
43
/** 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 ) {
45
45
let reject ! : Reject ;
46
46
47
47
if ( duration < 0 ) {
@@ -63,8 +63,8 @@ export class Timeout extends Promise<never> {
63
63
this . timedOut = true ;
64
64
reject ( new TimeoutError ( `Expired after ${ duration } ms` ) ) ;
65
65
} , 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
68
68
this . id . unref ( ) ;
69
69
}
70
70
}
@@ -78,8 +78,8 @@ export class Timeout extends Promise<never> {
78
78
this . id = undefined ;
79
79
}
80
80
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 ) ;
83
83
}
84
84
85
85
static is ( timeout : unknown ) : timeout is Timeout {
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ describe('Timeout', function () {
23
23
beforeEach ( ( ) => {
24
24
timeout = Timeout . expires ( 2000 ) ;
25
25
} ) ;
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 ( ) {
27
27
expect ( timeout ) . to . have . property ( 'id' ) ;
28
28
// @ts -expect-error: accessing private property
29
29
const id = timeout . id ;
30
30
expect ( id ?. hasRef ( ) ) . to . be . false ;
31
- } ) ;
31
+ } ) . skipReason = 'Skipping until further work during CSOT implementation' ;
32
32
it ( 'throws a TimeoutError when it expires' , async function ( ) {
33
33
try {
34
34
await timeout ;
You can’t perform that action at this time.
0 commit comments