From 0fb1aaaccdbdbc16df401301a4bc25a54c5fdadc Mon Sep 17 00:00:00 2001 From: Stefan Zerkalica Date: Thu, 5 Dec 2024 15:36:24 +0300 Subject: [PATCH] $mol_wire_fiber, promise destructor --- wire/fiber/fiber.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wire/fiber/fiber.ts b/wire/fiber/fiber.ts index b09fc74f80a..75573ea1fa6 100644 --- a/wire/fiber/fiber.ts +++ b/wire/fiber/fiber.ts @@ -264,7 +264,7 @@ namespace $ { * Asynchronous execution. * It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside. */ - async async() { + async async_raw() { while( true ) { @@ -287,6 +287,14 @@ namespace $ { } } + + async() { + const promise = this.async_raw() as Promise & { destructor(): void } + + if (! promise.destructor) promise.destructor = () => this.destructor() + + return promise + } step() { return new Promise< null >( done => {