File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ export { Endpoint };
25
25
export const proxyMarker = Symbol ( "Comlink.proxy" ) ;
26
26
export const createEndpoint = Symbol ( "Comlink.endpoint" ) ;
27
27
export const releaseProxy = Symbol ( "Comlink.releaseProxy" ) ;
28
+ export const finalizer = Symbol ( "Comlink.finalizer" ) ;
28
29
29
30
const throwMarker = Symbol ( "Comlink.thrown" ) ;
30
31
@@ -345,6 +346,9 @@ export function expose(obj: any, ep: Endpoint = self as any) {
345
346
// detach and deactive after sending release response above.
346
347
ep . removeEventListener ( "message" , callback as any ) ;
347
348
closeEndPoint ( ep ) ;
349
+ if ( finalizer in obj && typeof obj [ finalizer ] === "function" ) {
350
+ obj [ finalizer ] ( ) ;
351
+ }
348
352
}
349
353
} ) ;
350
354
} as any ) ;
@@ -387,7 +391,7 @@ declare var FinalizationRegistry: FinalizationRegistry<Endpoint>;
387
391
388
392
const proxyCounter = new WeakMap < Endpoint , number > ( ) ;
389
393
const proxyFinalizers =
390
- "FinalizationRegstry " in self &&
394
+ "FinalizationRegistry " in self &&
391
395
new FinalizationRegistry ( ( ep : Endpoint ) => {
392
396
const newCount = ( proxyCounter . get ( ep ) || 0 ) - 1 ;
393
397
proxyCounter . set ( ep , newCount ) ;
You can’t perform that action at this time.
0 commit comments