codex-plugin-cc icon indicating copy to clipboard operation
codex-plugin-cc copied to clipboard

Background task hangs indefinitely — no timeout on Codex API response generation

Open butmasaru opened this issue 8 months ago • 4 comments

Bug

Background tasks (/codex:rescue, /codex:task) can hang indefinitely when the Codex API stalls during response generation. There is no timeout mechanism to recover from this state.

Observed Behavior

  1. Task starts successfully, Codex reads files and runs commands (visible in log)
  2. After all tool calls complete, Codex enters response generation phase
  3. Log file stops updating — no new entries for 8+ minutes
  4. Task remains in status: "running" forever
  5. result <job-id> returns "No job found" because it only queries completed/failed/cancelled jobs
  6. cancel <job-id> fails because the OS process has already exited (but the job record was never updated)

Root Cause (suspected)

Two issues compound:

1. No response timeout

tracked-jobs.mjs runTrackedJob awaits the Codex API call without a timeout. If the API stalls during generation, the job hangs indefinitely.

2. Job state not updated on process exit

When the Codex process exits unexpectedly (or the API connection drops), the job record in the state file is never transitioned from running to failed. This leaves orphaned running jobs that:

  • Can't be queried via result (which filters for completed/failed/cancelled only)
  • Can't be cancelled (process already gone)
  • Block task-resume-candidate from working correctly

Expected Behavior

  • Tasks should have a configurable timeout (e.g., 5 minutes of no activity)
  • If the process exits without updating job state, the companion should detect orphaned jobs and mark them as failed
  • result should provide partial output for timed-out or orphaned jobs

Environment

  • Windows 11 Pro 10.0.26200
  • Node.js (latest)
  • codex-plugin-cc 1.0.1
  • Claude Code (latest)
  • Codex CLI 0.117.0

Reproduction

  1. Run a /codex:rescue task with a complex, multi-file review prompt
  2. Wait for Codex to complete its tool calls (file reads, greps)
  3. Observe the log file — after the last command completes, no further output appears
  4. status --json shows the task as running with increasing elapsed time
  5. The task never completes

Log excerpt

[06:29:06] Assistant message: キャンセル処理は一箇所だけ直しても意味がない場合があります...
[06:29:06] Running command: powershell -Command 'Get-Content Goudy....'
[06:29:07] Command completed (exit 0)
[06:29:07] Command completed (exit 0)
[06:29:07] Command completed (exit 0)
[06:29:07] Command completed (exit 0)
— (no further log entries for 8+ minutes, task stays "running") —

Note

This was observed after locally patching the spawn codex ENOENT issue (#32 / #46). The task successfully starts and runs commands, but hangs during the final response generation.

butmasaru avatar Mar 31 '26 06:03 butmasaru

Exactly the same issue, making codex plugin completely unusable.

DmitriyYukhanov avatar Apr 16 '26 12:04 DmitriyYukhanov

been having this issue too on 1.0.3. occasionally it seems to work. Most times in hangs. I just type "have codex review your work". Possibly related to https://github.com/openai/codex-plugin-cc/issues/234

amit777 avatar Apr 18 '26 17:04 amit777

+1 — hit this concretely. Running /codex:rescue from a Claude Code session, if Codex CLI can't reach the OpenAI API (network down, DNS misconfigured), the companion hangs forever on 'await state.completion' in captureTurn. No turn-level timeout, no abort. The rejectCompletion in the turn-capture state is dead code — zero call sites. The host's external timeout eventually SIGKILLs the process with no output. PR #376 (@russjhammond) addresses exactly this and looks like the right fix.

axisrow avatar Jul 20 '26 12:07 axisrow

Duplicate of #520.

dkundel-openai avatar Aug 11 '26 00:08 dkundel-openai