File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ export class WindowsScriptingHost extends EventEmitter {
1717 }
1818
1919 #syncline;
20+ #closed = false ;
2021 #finalizer = new FinalizationRegistry ( this . #finalized. bind ( this ) ) ;
2122 #ref2proxy = new Map ( ) ;
2223 #proxy2ref = new WeakMap ( ) ;
@@ -99,6 +100,7 @@ export class WindowsScriptingHost extends EventEmitter {
99100 }
100101
101102 async disconnect ( ) {
103+ this . #closed = true ;
102104 await this . #syncline. close ( ) ;
103105 }
104106
@@ -121,7 +123,8 @@ export class WindowsScriptingHost extends EventEmitter {
121123 #finalized( ref ) {
122124 if ( this . #ref2proxy. get ( ref ) . deref ( ) === undefined ) // otherwise, it's overwritten by a refreshed proxy
123125 this . #ref2proxy. delete ( ref ) ;
124- const output = this . #syncline. exchange ( JSON . stringify ( [ 'unref' , ref ] ) ) ;
126+ if ( ! this . #closed)
127+ this . #syncline. exchange ( JSON . stringify ( [ 'unref' , ref ] ) ) ;
125128 this . emit ( 'unref' , ref ) ;
126129 }
127130
You can’t perform that action at this time.
0 commit comments