Skip to content

fix(codex): raise thread handshake timeout - #846

Merged
chuks-qua merged 1 commit into
mainfrom
fix/codex-thread-handshake-timeout
Jul 8, 2026
Merged

chuks-qua merged 1 commit into
mainfrom
fix/codex-thread-handshake-timeout

Conversation

@chuks-qua

@chuks-qua chuks-qua commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Raise the Codex app-server thread handshake budget from 15 seconds to 30 seconds.

Why

Recent Codex builds can take longer than 15 seconds to start or resume a thread after the app-server initializes. Mcode reported Timed out waiting for thread/start (15000ms) before the provider could complete startup.

Key Changes

  • Adds a named THREAD_HANDSHAKE_TIMEOUT_MS constant for Codex thread start and resume.
  • Adds tests that assert thread/start and thread/resume use the 30 second budget and no longer use 15 seconds.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Increased the time allowed for Codex thread startup and resume after initialization, reducing the chance of premature handshake failures.
    • Improved reliability when resuming an existing thread or creating a new one, especially in slower environments.
    • Added coverage to ensure the updated timeout behavior remains consistent for both resume and start flows.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 641448b4-9924-406f-ab42-32793247f3f6

📥 Commits

Reviewing files that changed from the base of the PR and between 450005a and 6685608.

📒 Files selected for processing (2)
  • apps/server/src/providers/codex/__tests__/codex-app-server-handshake.test.ts
  • apps/server/src/providers/codex/codex-app-server.ts

📝 Walkthrough

Walkthrough

This PR adds a dedicated THREAD_HANDSHAKE_TIMEOUT_MS constant (30 seconds) in the Codex app-server, replacing the previously hardcoded 15-second timeout used for thread/resume and thread/start RPC calls during handshake. Two new tests validate the updated timeout values via setTimeout spies.

Changes

Thread Handshake Timeout Update

Layer / File(s) Summary
Add timeout constant and apply to handshake calls
apps/server/src/providers/codex/codex-app-server.ts
Introduces THREAD_HANDSHAKE_TIMEOUT_MS (30,000ms) and replaces the hardcoded 15s timeout in thread/resume and thread/start RPC requests within runHandshake.
Tests validating raised timeout budgets
apps/server/src/providers/codex/__tests__/codex-app-server-handshake.test.ts
Adds tests spying on global.setTimeout to confirm 30,000ms is scheduled for thread/start and thread/resume, and that the old 15,000ms value is no longer present.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CodexAppServer
  participant CodexProcess

  Client->>CodexAppServer: start()
  CodexAppServer->>CodexProcess: initialize
  CodexProcess-->>CodexAppServer: initialized
  alt resumeThreadId provided
    CodexAppServer->>CodexProcess: thread/resume (timeout=THREAD_HANDSHAKE_TIMEOUT_MS)
  else new thread
    CodexAppServer->>CodexProcess: thread/start (timeout=THREAD_HANDSHAKE_TIMEOUT_MS)
  end
  CodexProcess-->>CodexAppServer: thread ready
Loading

Possibly related PRs

  • Mzeey-Empire/mcode#247: Rewrites the same thread/resume/thread/start session-resume handshake flow in codex-app-server.ts.

Poem

A rabbit hops with timers new,
Thirty seconds, not fifteen, will do!
thread/start and thread/resume take a breath,
No more racing timeout's death.
Hop, hop, hooray — tests confirm it true! 🐇⏱️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: increasing the Codex thread handshake timeout.
Description check ✅ Passed The description covers What, Why, and Key Changes; the Config Changes section is omitted but no config changes were made.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chuks-qua
chuks-qua merged commit 877a622 into main Jul 8, 2026
10 checks passed
@chuks-qua
chuks-qua deleted the fix/codex-thread-handshake-timeout branch July 8, 2026 14:27
@mze-bot mze-bot Bot mentioned this pull request Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant