Skip to content

fix(run-codex-exec): handle stdin EPIPE gracefully and pass prompt via env - #162

Open
Alphaxiaoteng wants to merge 1 commit into
openai:mainfrom
Alphaxiaoteng:fix/handle-stdin-epipe-and-hide-prompt-argv
Open

fix(run-codex-exec): handle stdin EPIPE gracefully and pass prompt via env#162
Alphaxiaoteng wants to merge 1 commit into
openai:mainfrom
Alphaxiaoteng:fix/handle-stdin-epipe-and-hide-prompt-argv

Conversation

@Alphaxiaoteng

Copy link
Copy Markdown

Summary

  1. Safely handles stdin stream errors and premature Codex exits (Fixes Fast Codex exits can crash the action with an unhandled stdin EPIPE #153): Observes error events on child.stdin in runCodexExec() so fast startup exits or unhandled EPIPE exceptions do not crash the action process as an unhandled EventEmitter error.
  2. Keeps inline prompt bytes out of intermediate helper argv (Fixes Inline prompts are copied into the action helper process argv #154): Adds support for --prompt-env in run-codex-exec, and switches action.yml to pass the prompt via environment variable name rather than expanding full prompt text into node dist/main.js command line arguments (preventing command-line length limits on Windows and unnecessary process listing exposure).

Changes

  • src/runCodexExec.ts:
    • Extended PromptSource with { type: "env", variableName: string }.
    • Added child.stdin.on("error", ...) handler to gracefully ignore EPIPE and settle the supervision promise with the child's actual exit code.
    • Wrapped resolve/reject to prevent double-settlement if pipe closes concurrently.
  • src/main.ts:
    • Added --prompt-env CLI option for run-codex-exec.
    • Updated emptyAsNull() to safely handle undefined options.
  • action.yml:
    • Dynamically passes --prompt-env CODEX_PROMPT when inputs.prompt is set, avoiding putting the whole prompt body in argv.
  • test/stdinEpipeAndPromptEnv.test.mjs:
    • Added unit test verifying multiline prompt extraction via --prompt-env.
    • Added regression test verifying fast child exit (process.exit(42)) with in-flight stdin write settles cleanly with exit code 42 without uncaught EPIPE exceptions.

Verification

  • npm run build cleanly compiled with esbuild.
  • npm test passed: 146/146 tests passing.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Alphaxiaoteng
Alphaxiaoteng force-pushed the fix/handle-stdin-epipe-and-hide-prompt-argv branch from efcdc65 to c119e2e Compare August 25, 2026 07:50
@Alphaxiaoteng

Copy link
Copy Markdown
Author

recheck

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.

Inline prompts are copied into the action helper process argv Fast Codex exits can crash the action with an unhandled stdin EPIPE

1 participant