Skip to content

fix codex exec hangs forever issue#154

Open
mirusu400 wants to merge 2 commits intotuannvm:mainfrom
mirusu400:main
Open

fix codex exec hangs forever issue#154
mirusu400 wants to merge 2 commits intotuannvm:mainfrom
mirusu400:main

Conversation

@mirusu400
Copy link
Copy Markdown

@mirusu400 mirusu400 commented Apr 9, 2026

Summary

When codex-mcp-server is used as an MCP server inside Claude Code (or any MCP client), the codex tool hangs indefinitely. The codex exec subprocess never completes because it waits for stdin EOF that never arrives. So I fix it

Changes

  • src/utils/command.ts

Testing

  • Tests pass locally
  • New tests added (if applicable)

Related Issues

Fixes #153

Summary by CodeRabbit

  • Bug Fixes

    • Improved process execution reliability by ensuring spawned processes properly close their input stream to avoid hangs and improve stability.
  • New Features

    • Updated default code model and added new model options, expanding available choices for code-related tasks and improving model selection.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

Warning

Rate limit exceeded

@mirusu400 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 1 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 6 minutes and 1 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 143e21da-fd39-486f-b3ba-8c619c90f712

📥 Commits

Reviewing files that changed from the base of the PR and between 2b93093 and 534f9c5.

📒 Files selected for processing (2)
  • src/types.ts
  • src/utils/command.ts

Walkthrough

Both fixes: (1) explicitly close spawned processes' stdin in command execution functions to avoid hangs; (2) update Codex default model and available model list to include gpt-5.4 variants and a new spark entry.

Changes

Cohort / File(s) Summary
stdin closure
src/utils/command.ts
Adds child.stdin.end() immediately after spawn(...) in both executeCommand and executeCommandStreaming to close stdin and prevent child processes from blocking while waiting for input.
model defaults & list
src/types.ts
Changes DEFAULT_CODEX_MODEL from gpt-5.3-codexgpt-5.4; extends AVAILABLE_CODEX_MODELS to add gpt-5.4, gpt-5.4-mini, and gpt-5.3-codex-spark.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰
I closed the pipe with a gentle tap,
No more waiting, no more trap.
Processes skip and hop with glee,
Models bumped to five point four, whee!
Hangs are gone — the meadow's free. 🌿✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes an out-of-scope change: updating Codex model constants and available models in src/types.ts is unrelated to the stdin hang fix in issue #153. Remove changes to DEFAULT_CODEX_MODEL and AVAILABLE_CODEX_MODELS from src/types.ts as they are not related to fixing the codex exec hang issue described in #153.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix codex exec hangs forever issue' directly addresses the main objective: fixing a hang in the codex exec subprocess.
Linked Issues check ✅ Passed The PR successfully implements the fix described in issue #153 by calling child.stdin.end() after spawning in both executeCommand and executeCommandStreaming, preventing the stdin hang.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/utils/command.ts (1)

62-62: Please add a regression test for the stdin-EOF hang path.

This bug is easy to reintroduce; a focused test that verifies executeCommand* completes when no stdin is provided would lock in the fix.

Also applies to: 167-167

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/command.ts` at line 62, Add a regression test that verifies the
stdin-EOF hang is fixed by exercising the executeCommand* entry points (e.g.,
executeCommand and any related exported variants) with no stdin supplied and
asserting the promise completes (resolves) rather than hanging; simulate a child
process that would otherwise wait for stdin, call the function without writing
to stdin, and use a short test timeout or explicit completion assertion to fail
if it blocks — this ensures child.stdin.end() behavior is exercised and prevents
future regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/utils/command.ts`:
- Line 62: Add a regression test that verifies the stdin-EOF hang is fixed by
exercising the executeCommand* entry points (e.g., executeCommand and any
related exported variants) with no stdin supplied and asserting the promise
completes (resolves) rather than hanging; simulate a child process that would
otherwise wait for stdin, call the function without writing to stdin, and use a
short test timeout or explicit completion assertion to fail if it blocks — this
ensures child.stdin.end() behavior is exercised and prevents future regressions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b081c752-4792-4b18-b914-a979660c7776

📥 Commits

Reviewing files that changed from the base of the PR and between 5bb7935 and 509a613.

📒 Files selected for processing (1)
  • src/utils/command.ts

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/types.ts`:
- Line 16: Tests failing because they hardcode the old model string; import and
use the exported DEFAULT_CODEX_MODEL constant in the test instead of expecting
the literal 'gpt-5.3-codex' so future changes won’t break; in
default-model.test.ts add an import for DEFAULT_CODEX_MODEL from src/types and
replace the assertions that compare to the hardcoded model (the two assertion
blocks around the previously failing snippets) to assert against
DEFAULT_CODEX_MODEL.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e24c1ff5-b5c0-4f99-8212-38f335353ce1

📥 Commits

Reviewing files that changed from the base of the PR and between 509a613 and 2b93093.

📒 Files selected for processing (1)
  • src/types.ts


// Codex model constants
export const DEFAULT_CODEX_MODEL = 'gpt-5.3-codex' as const;
export const DEFAULT_CODEX_MODEL = 'gpt-5.4' as const;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Update default-model tests for the Line 16 constant change.

Changing DEFAULT_CODEX_MODEL to gpt-5.4 will break current hardcoded expectations in src/__tests__/default-model.test.ts (snippets at lines 43-63 and 101-124 still expect gpt-5.3-codex). Please update those assertions, ideally by referencing DEFAULT_CODEX_MODEL in tests to prevent future drift.

Suggested test-side adjustment
- 'gpt-5.3-codex'
+ DEFAULT_CODEX_MODEL
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/types.ts` at line 16, Tests failing because they hardcode the old model
string; import and use the exported DEFAULT_CODEX_MODEL constant in the test
instead of expecting the literal 'gpt-5.3-codex' so future changes won’t break;
in default-model.test.ts add an import for DEFAULT_CODEX_MODEL from src/types
and replace the assertions that compare to the hardcoded model (the two
assertion blocks around the previously failing snippets) to assert against
DEFAULT_CODEX_MODEL.

Signed-off-by: mirusu400 <mirusu400@naver.com>
Signed-off-by: mirusu400 <mirusu400@naver.com>
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.

Bug: codex exec hangs forever when spawned with stdio pipe — stdin never closed

1 participant