File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 11import * as events from 'node:events' ;
2- import { timeout } from '../time' ;
2+ import { timeout , waiter } from '../time' ;
33
44describe ( 'Helper tests' , ( ) => {
55 test ( 'timeout function should not cause memory leak by accumulating abort listeners on abort' , async ( ) => {
@@ -49,4 +49,11 @@ describe('Helper tests', () => {
4949 // Final check to confirm listeners are cleaned up
5050 expect ( countListeners ( ) ) . toBe ( 0 ) ;
5151 } ) ;
52+
53+ test ( 'waiter is finished' , async ( ) => {
54+ const myWaiter = waiter ( ) ;
55+ myWaiter . finish ( ) ;
56+ await myWaiter ;
57+ expect ( myWaiter . isFinished ) . toBe ( true ) ;
58+ } ) ;
5259} ) ;
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ export function waiter<T = void>(): Waiter<T> {
121121 } ) ;
122122 const completer = {
123123 finish : ( result : T ) => {
124- completer . isFinished = true ;
124+ void Object . assign ( promise , { isFinished : true } ) ;
125125 resolveFn ( result ) ;
126126 } ,
127127 isFinished : false ,
You can’t perform that action at this time.
0 commit comments