fix(server): bound Codex session startup to release stalled commands #11471
main fromrefs/pull/11471/head·opened View on GitHubA Codex app-server that never finishes initialization or thread resume leaves startSession pending and holds the sequential provider command worker, so later sessions cannot start.
Bound Codex startup to 30 seconds and route the timeout through the existing failure cleanup. The runtime, session scope, and event consumer are released, and the caller receives an actionable error. A regression test verifies resource cleanup and that the next session starts successfully.
Validation:
- The new regression test fails on the original code and passes with the fix.
- All 53
CodexAdaptertests pass. - Server package typecheck and lint for both changed files pass.
- The equivalent guard was verified against a stalled local peer and the installed server; a fresh live session completed successfully after restart.
Authored with OpenAI Codex (GPT-6).
Summary by CodeRabbit#
- Bug Fixes
- Codex sessions that stall during startup now time out after 30 seconds instead of waiting indefinitely.
- Failed session attempts now clean up associated resources and can be followed by a successful new session.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
cd1375fMacroscope's review found this PR approvable — This is a focused Codex startup bug fix that bounds stalled handshakes, invokes existing resource cleanup, and verifies that subsequent sessions can start. The normal startup path and product configuration remain unchanged.
No code changes detected at
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).7488842. Prior analysis still applies.No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
ed8596f6-5055-4fa4-978c-9f166c60a36a📥 Commits
Reviewing files that changed from the base of the PR and between 03e135577cbf861c2948981601c070dab038ea11 and cd1375f1b3cf9d34be3c390a8c30ce466fe8e686.
📒 Files selected for processing (2)
apps/server/src/provider/Layers/CodexAdapter.test.tsapps/server/src/provider/Layers/CodexAdapter.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
Codex session startup now fails after 30 seconds when the runtime handshake stalls. Error cleanup closes the runtime, session scope, and event fiber. A regression test verifies scope release and successful startup of a subsequent session.
Changes#
Codex session lifecycle
Layer / File(s) Summary Startup timeout and scope cleanup
apps/server/src/provider/Layers/CodexAdapter.ts,apps/server/src/provider/Layers/CodexAdapter.test.tsstartSessionapplies a 30-second timeout toruntime.start()and raisesProviderAdapterProcessErroron timeout. The test verifies cleanup, failed-session removal, and successful startup and shutdown of a later session.Priority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers:
t3dotggMerge Risk: ⚪ Minimal · up to
74888Stalled Codex session startup is bounded and cleaned up, with regression coverage for recovery by a later session.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation Description check ✅ Passed The description clearly explains what changed, why the change is needed, the cleanup behavior, regression coverage, and validation results. It does not use the template headings or an explicit checkli… Title check ✅ Passed The title is concise and accurately describes the primary change: bounding Codex session startup to release stalled commands. Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2… Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. ✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Comment `@coderabbitai help` to get the list of available commands.juliusmarminge added labelsmacroscope-review
Thanks for working on this. We merged the orchestrator V2 rewrite in #2829, and we are closing this PR as part of that transition.
This change touches CodexAdapter.ts, which the V2 merge removed. Codex execution now uses CodexAdapterV2 and the generated app-server integration.
Sorry for the extra work this creates. If the change is still needed on V2, please rebuild it on current main, verify it there, and open a new PR linking back here. We're closing the current implementation without assuming the underlying request is resolved.
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes