Repository navigation
fix(runtime): helper-lifecycle follow-ups (#666, #667, #668) and a detached-reap regression #669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
52d92c1
fix(codex): stop runtime helpers from leaking past their idle timeout
possibilities f5bf873
fix(codex): address CodeRabbit round 1 on the helper-leak fix
possibilities 1590cd1
test(codex): pin the sweep-retry test to the four-attempt budget, ord…
possibilities 6bb2049
fix(codex): reap app helpers stranded by the detach grace
possibilities c18a5df
fix(codex): degrade an unreadable connection count to zero
possibilities c03af14
fix(codex): correct the connection-count comment and cover the reap o…
possibilities e57da41
fix(codex): accept only a positive socket count as evidence of a cons…
possibilities 16a335f
test: add owned-PID probes for helper-lifecycle fixtures (#668)
ndycode bf0a749
fix(codex): reap only helpers that were never handed to a consumer
ndycode 040e0c1
fix(runtime): stop unbind from orphaning helper owner files (#666)
ndycode 7c10722
refactor(runtime): one identity-checked helper selector for both read…
ndycode 109db04
docs: correct the runtime app helper status path in the README
ndycode 51c5ca4
refactor(runtime): narrow the helper PID instead of casting it
ndycode c42bf54
fix(runtime): address the review on the helper-lifecycle follow-ups
ndycode e087c43
test: stress the helper lifecycle at the scale the leak report described
ndycode 8f0b578
test: fix the review round on the stress suite
ndycode 6b9f327
test: make the spawn-failure coverage exercise the helpers, not node
ndycode 02e0c9b
test: cover the failed-spawn branch in withLivePid
ndycode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(codex): reap only helpers that were never handed to a consumer
The detached reap added in #665 could kill a live `codex app` session. `codex app` relies on the detach grace rather than an explicit `detachOnExit`, so its launcher exits inside the grace window and the helper's owner is dead from the first tick. From then on the only thing standing between the desktop app and a dead proxy was `countOpenConnections() === 0` — and the proxy never sets `server.keepAliveTimeout`, so Node closes idle client sockets after its 5s default. A user who stops typing for the length of the detached window has zero sockets and no new requests, so the helper exits `owner-gone`, and the next message gets ECONNREFUSED against a dead localhost port with nothing left to restart it. Pre-#665 that session survived for the full 12h idle timeout. Gate the reap on the helper having *never* served a request. Every leaked helper in the #663 report had `totalRequests: 0`, so the leak is entirely a never-served phenomenon and the narrower gate closes it in full; a helper that served anything was genuinely handed off and falls back to the idle timeout and the 24h lifetime ceiling, which is where it sat before the detached window existed. Two more lifecycle fixes in the same tick: - The owner verdict is now three-valued. "No owner PID was recorded" and "the owner is confirmed dead" are different facts, and collapsing them into one `false` started the detached clock on the first tick for any helper launched without an owner PID — invoked directly, which is the documented reproduction in #663, or spawned by a pre-upgrade launcher — and reaped it silently 15 minutes later. `unknown` fires neither branch, which is what the pre-#664 `ownerPid && isAlive(ownerPid)` guard did. - The status heartbeat now accounts for the detached window. `publishToken` zeroes `idleExpiresAt`, so the published deadline only catches up on a heartbeat; pinned to the idle window alone, `rotation status` kept advertising a 12h deadline for a helper seconds from exiting, and under a short DETACHED_IDLE_MS override it never caught up at all. Also in this commit, both from the same review pass: - The metadata sweep runs after the helper spawn instead of before it. It is synchronous and unbounded — readdir, a readFileSync per live candidate, rmSync with a blocking backoff, bounded `ps` probes — and the state it cleans up is exactly the state that makes it slow, so it sat in front of `codex app` and TUI startup. Nothing about spawning depends on it. The launch timeout is armed after it either way. - Sweep deletions are guarded by an mtime re-check. Classifying a file as stale and deleting it are two moments, and a PID freed between them can be handed to a helper starting right now, which republishes that exact path before the delete lands. - The published wrapper's fault injectors need an explicit CODEX_MULTI_AUTH_TEST_FAULT_INJECTION=1 opt-in and a strict digits-only parse. `Number.parseInt` reads "2abc" as 2 and "1e3" as 1, so a value that was never meant to be a count could arm an injector in a user's install and silently defeat the first N metadata deletions of every sweep (#668). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015b4Lew3oHNEYmTZtg7zEWz
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.