From 66a606c14e0b57bdf9d5baa29563c6c40189eb79 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Mon, 16 Mar 2026 20:07:59 -0600 Subject: [PATCH] fix: prevent consts from triggering after leaving effect context --- container-runtime/src/Adapters/RpcListener.ts | 7 ++----- container-runtime/src/Adapters/Systems/SystemForStartOs.ts | 2 +- sdk/base/lib/util/Watchable.ts | 6 ++++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/container-runtime/src/Adapters/RpcListener.ts b/container-runtime/src/Adapters/RpcListener.ts index f9dd0fac2..4f51e5278 100644 --- a/container-runtime/src/Adapters/RpcListener.ts +++ b/container-runtime/src/Adapters/RpcListener.ts @@ -298,13 +298,10 @@ export class RpcListener { } case "stop": { const { id } = stopType.parse(input) + this.callbacks?.removeChild("main") return handleRpc( id, - this.system.stop().then((result) => { - this.callbacks?.removeChild("main") - - return { result } - }), + this.system.stop().then((result) => ({ result })), ) } case "exit": { diff --git a/container-runtime/src/Adapters/Systems/SystemForStartOs.ts b/container-runtime/src/Adapters/Systems/SystemForStartOs.ts index 3b0d767ed..adf76aa44 100644 --- a/container-runtime/src/Adapters/Systems/SystemForStartOs.ts +++ b/container-runtime/src/Adapters/Systems/SystemForStartOs.ts @@ -71,7 +71,7 @@ export class SystemForStartOs implements System { this.starting = true effects.constRetry = utils.once(() => { console.debug(".const() triggered") - effects.restart() + if (effects.isInContext) effects.restart() }) let mainOnTerm: () => Promise | undefined const daemons = await ( diff --git a/sdk/base/lib/util/Watchable.ts b/sdk/base/lib/util/Watchable.ts index 22c2d3581..b65d24a2b 100644 --- a/sdk/base/lib/util/Watchable.ts +++ b/sdk/base/lib/util/Watchable.ts @@ -83,10 +83,12 @@ export abstract class Watchable { const constRetry = this.effects.constRetry const cleanup = this.onConstRegistered(value) gen.next().then( - () => { + (a) => { abort.abort() cleanup?.() - constRetry() + if (!a.done) { + constRetry() + } }, () => { abort.abort()