fix(codex): say a full Stop wait can overrun quit's eviction budget, and don't let its timer hold the process (#23859)

This commit is contained in:
Brennan Benson
2026-09-29 17:25:12 -07:00
committed by GitHub
parent fed1eca486
commit 69b1e40c6b
2 changed files with 5 additions and 2 deletions
@@ -21,8 +21,9 @@ function providerTurnId(session: CodexSession, turnId: string): string | undefin
return session.translator ? session.translator.commandProviderTurnId(turnId) : turnId
}
/** 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
/**
@@ -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) => {