Repository navigation
fix(codex): improve app-server exit diagnostics - #841
Conversation
|
Warning Review limit reached
Next review available in: 16 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughCodexAppServer replaces its single last-stderr string with a bounded StderrTail buffer capturing multiple non-benign lines, and adds decoded exit diagnostics for unexpected child exits. CodexEventMapper adds a new WarningNotificationPayload type and logs "warning" notifications instead of treating them as unrecognized. Tests extended accordingly. ChangesCodex exit diagnostics and warning notification handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Child as Codex child process
participant AppServer as CodexAppServer
participant StderrTail as StderrTail buffer
participant Logger as logger
Child->>AppServer: stderr line
AppServer->>AppServer: classify (benign/non-benign)
AppServer->>StderrTail: append non-benign line
Child->>AppServer: exit(code, signal)
AppServer->>AppServer: decodeExitDiagnostics(code, signal)
AppServer->>StderrTail: latest()/snapshot
AppServer->>AppServer: formatUnexpectedExitMessage(diagnostics, stderrTail)
AppServer->>Logger: error(message, structured stderrTail fields)
AppServer->>AppServer: emit "fatal" event
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The user-facing fatal message embedded the latest stderr line verbatim, up to 16KB and attacker-influenceable. It flows into the web CliErrorBanner, which lifts backtick-quoted substrings out as copyable commands. Cap the excerpt at 256 code points and strip backticks; the full bounded line stays in the structured stderrTail log fields. Also remove dead threadId/turnId fields from WarningNotificationPayload (warnings are logged wholesale, never routed per-thread), read the latest stderr line through StderrTail.latest() in wireExit, and document the single-line floor invariant in StderrTail.evict().
What
Improves Codex app-server crash diagnostics and Codex warning notification logging.
Why
When the Codex app-server exited unexpectedly, Mcode showed a raw exit code and dropped the child process stderr. Codex warning notifications also fell through the unknown-notification path, so their payloads were not recorded at warn level.
Key Changes
exited unexpectedlybanner trigger.warningnotifications at warn level with their payload.Verification
cd apps/server && bun run test src/providers/codex/__tests__/codex-app-server-handshake.test.ts src/providers/codex/__tests__/codex-event-mapper.test.ts src/providers/codex/__tests__/codex-protocol-coverage.test.ts: 3 files, 92 tests passed.bun run verify: typecheck, lint, and unit tests passed.live stub stderr cause from issue 840to stderr;CodexAppServeremitted anexited unexpectedlyfatal with that line inlatest stderrandstderrTail.Fixes #840
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
Bug Fixes