Skip to content

feat: turn-level timeout — Codex hangs forever when API is unreachable (openai#49) #25

Description

@axisrow

Problem

If Codex CLI can't reach the OpenAI API (network down, DNS misconfigured, MITM redirect), the companion hangs forever. No turn-level timeout exists:

  • captureTurn (codex.mjs:556) ends in 'return await state.completion' — a Promise resolved only by turn/completed or a 250ms inferred-completion fallback. If Codex is alive but silent (stalled on a network request), neither fires.
  • rejectCompletion exists in the turn-capture state (codex.mjs:303) but has ZERO call sites — dead code.
  • runTrackedJob (tracked-jobs.mjs) has no AbortController, no deadline.
  • exitPromise (app-server.mjs) only fires if the Codex process DIES. A stalled-but-alive process keeps exitPromise pending.

Result: companion blocks indefinitely. The only escape is the host's external timeout (Bash tool ~2 min) SIGKILLing the process with no output.

Upstream

openai#49 — exact issue. openai#489 — duplicate.
openai#376 (@russjhammond) — ready PR: wires rejectCompletion to client.exitPromise + makes turn budget configurable via CODEX_TURN_TIMEOUT_MS. +99/-3, 2 files, author addressed review feedback.

Plan

Port openai#376 into this fork, cycle-review, fix any bugs found, merge. Gift findings back to upstream openai#376.

Refs openai#49, openai#489, openai#376.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions