From 7a55d542a77ece69a880cae3432c4c9834c47acf Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Tue, 29 Sep 2026 03:17:17 -0700 Subject: [PATCH] fix(codex): say a full Stop wait can overrun quit's eviction budget, and don't let its timer hold the process --- src/main/codex/codex-structured-prompt-ownership.ts | 5 +++-- src/main/codex/codex-structured-turn-open-wait.ts | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/codex/codex-structured-prompt-ownership.ts b/src/main/codex/codex-structured-prompt-ownership.ts index 1742d5ced697..4095a3a75b08 100644 --- a/src/main/codex/codex-structured-prompt-ownership.ts +++ b/src/main/codex/codex-structured-prompt-ownership.ts @@ -17,8 +17,9 @@ import type { CodexStructuredTurnCancellation } from './codex-structured-turn-ca type CancelInput = Parameters[0] type AnswerInput = Parameters[0] -/** How long a Stop waits for Codex to open the turn it answered a send into. Under the quit - * path's eviction budget, which a close or quit queued behind the Stop spends. */ +/** How long a Stop waits for Codex to open the turn it answered a send into. A close or quit queued + * behind the Stop spends this out of the eviction budget, so a full wait plus a slow provider + * close can overrun it; the next launch's recovery then settles the lease. */ export const CODEX_STOP_TURN_OPEN_WAIT_MS = 5_000 /** diff --git a/src/main/codex/codex-structured-turn-open-wait.ts b/src/main/codex/codex-structured-turn-open-wait.ts index 63e372940058..1e303a58fba8 100644 --- a/src/main/codex/codex-structured-turn-open-wait.ts +++ b/src/main/codex/codex-structured-turn-open-wait.ts @@ -34,6 +34,8 @@ export function createCodexTurnOpenWaits(): CodexTurnOpenWaits { resolve() } const bound = setTimeout(endWait, withinMs) + // A Stop's wait must never be what keeps the process alive at quit. + bound.unref?.() waits.set(endWait, turnId) }), observe: (threadId, method, params) => {