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 } + ) }