openai/codex · error · Error

Codex Exec exited with

Error message

Codex Exec exited with ${detail}: ${stderrBuffer.toString("utf8")}

What it means

The Codex exec child process exited abnormally — non-zero exit code or a termination signal (the detail names which) — and the buffered stderr is appended to the message. This is the terminal failure for an exec run that crashed or was killed.

Solutions

  1. Read the stderr text in the message for the exit cause, fix the underlying problem, and rerun codex exec.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at sdk/typescript/src/exec.ts:247 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/0dbd92d80f84f0f5. Report an issue: GitHub.

Appendix: source

Thrown at sdk/typescript/src/exec.ts:247

    );

    const rl = readline.createInterface({
      input: child.stdout,
      crlfDelay: Infinity,
    });

    try {
      for await (const line of rl) {
        // `line` is a string (Node sets default encoding to utf8 for readline)
        yield line as string;
      }

      if (spawnError) throw spawnError;
      const { code, signal } = await exitPromise;
      if (code !== 0 || signal) {
        const stderrBuffer = Buffer.concat(stderrChunks);
        const detail = signal ? `signal ${signal}` : `code ${code ?? 1}`;
        throw new Error(`Codex Exec exited with ${detail}: ${stderrBuffer.toString("utf8")}`);
      }
    } finally {
      rl.close();
      child.removeAllListeners();
      try {
        if (!child.killed) child.kill();
      } catch {
        // ignore
      }
    }
  }
}

function serializeConfigOverrides(configOverrides: CodexConfigObject): string[] {
  const overrides: string[] = [];
  flattenConfigOverrides(configOverrides, "", overrides);
  return overrides;
}

View on GitHub (pinned to 339751715c)