From 381921e4e6d77faf49eb8898b8af8c511dda9fe3 Mon Sep 17 00:00:00 2001 From: jin Date: Fri, 13 Dec 2024 01:57:02 +0300 Subject: [PATCH] $mol_wire_fiber: fixed promise destructor propagation --- wire/fiber/fiber.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/wire/fiber/fiber.ts b/wire/fiber/fiber.ts index 75573ea1fa..706643d34d 100644 --- a/wire/fiber/fiber.ts +++ b/wire/fiber/fiber.ts @@ -181,11 +181,15 @@ namespace $ { if( $mol_promise_like( result ) && !handled.has( result ) ) { + handled.add( result ) const put = ( res: Result )=> { if( this.cache === result ) this.put( res ) return res } - result = result.then( put, put ) + result = Object.assign( + result.then( put, put ), + { destructor: ( result as any ).destructor } + ) } @@ -199,9 +203,13 @@ namespace $ { if( $mol_promise_like( result ) && !handled.has( result ) ) { - result = result.finally( ()=> { - if( this.cache === result ) this.absorb() - } ) + handled.add( result ) + result = Object.assign( + result.finally( ()=> { + if( this.cache === result ) this.absorb() + } ), + { destructor: ( result as any ).destructor } + ) }