claude-code - 💡(How to fix) Fix CLI crash: stack-overflow recursion in AskUserQuestion render path while idle (no question pending) [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49595Fetched 2026-04-17 08:36:42
View on GitHub
Comments
2
Participants
2
Timeline
9
Reactions
0
Timeline (top)
labeled ×5commented ×2closed ×1cross-referenced ×1

CLI crashed with infinite-recursion stack dump while a foreground session was idle, waiting on sub-agent results. The crash dumped a large chunk of minified cli.js to the terminal and killed the foreground process; orphaned sub-agent sessions kept writing to their transcripts for ~3 minutes before stopping (presumably when their parent's death was detected).

The foreground assistant never invoked AskUserQuestion, EnterPlanMode, or ExitPlanMode — yet the crash trace is in the AskUserQuestion / plan-mode interview render path.

Error Message

sPHov looks like a React error-boundary / effect re-render loop. T+3.2s system stop_hook_summary (clean, no error)

  • If a render does fail, the error boundary should report and recover, not

Root Cause

CLI crashed with infinite-recursion stack dump while a foreground session was idle, waiting on sub-agent results. The crash dumped a large chunk of minified cli.js to the terminal and killed the foreground process; orphaned sub-agent sessions kept writing to their transcripts for ~3 minutes before stopping (presumably when their parent's death was detected).

The foreground assistant never invoked AskUserQuestion, EnterPlanMode, or ExitPlanMode — yet the crash trace is in the AskUserQuestion / plan-mode interview render path.

Code Example

- <anonymous> (cli.js:8231:15642)
- qX  (cli.js:477:63169)
- sPH (cli.js:477:76220)
- ov  (cli.js:477:76101)
- sPH (cli.js:477:76199)
- ov  (cli.js:477:76101)
- sPH (cli.js:477:76199)
- ov  (cli.js:477:76101)
...repeats...

---

T+0    user      <teammate-message teammate_id="quality-reviewer" summary="Worktree verified, ready for review">
                 Worktree verified at <worktree-path>. WORKTREE OK. Ready to receive tickets.
                 </teammate-message>

                 <teammate-message teammate_id="quality-reviewer">
                 {"type":"idle_notification","from":"quality-reviewer","idleReason":"available"}
                 </teammate-message>

T+3s   assistant TEXT: "Quality-reviewer verified. All 5 agents ready; 3 implementers
                       working. Awaiting DONE signals."

T+3.2s system    stop_hook_summary  (clean, no error)

[no further entries — transcript ends here]
RAW_BUFFERClick to expand / collapse

Environment

  • Claude Code: v2.1.112
  • Model: Opus 4.7 (claude-opus-4-7)
  • Platform: macOS 15.3 (Darwin arm64)

Description

CLI crashed with infinite-recursion stack dump while a foreground session was idle, waiting on sub-agent results. The crash dumped a large chunk of minified cli.js to the terminal and killed the foreground process; orphaned sub-agent sessions kept writing to their transcripts for ~3 minutes before stopping (presumably when their parent's death was detected).

The foreground assistant never invoked AskUserQuestion, EnterPlanMode, or ExitPlanMode — yet the crash trace is in the AskUserQuestion / plan-mode interview render path.

Workload shape

  • Foreground session was coordinating a team of 5 sub-agents running in parallel git worktrees, communicating via SendMessage.
  • At time of crash, foreground was idle, awaiting completion messages from the sub-agents. No user input was pending.

Crash trace (head + tail)

Crash site: cli.js:8231:15642 — inside the function that fires the tengu_ask_user_question_finish_plan_interview analytics event and awaits xf8(g, i) (image attachment processing) for the AskUserQuestion onAllow / onReject callbacks.

Stack tail shows tight recursion:

- <anonymous> (cli.js:8231:15642)
- qX  (cli.js:477:63169)
- sPH (cli.js:477:76220)
- ov  (cli.js:477:76101)
- sPH (cli.js:477:76199)
- ov  (cli.js:477:76101)
- sPH (cli.js:477:76199)
- ov  (cli.js:477:76101)
...repeats...

sPHov looks like a React error-boundary / effect re-render loop.

Transcript evidence

Final entries of the foreground transcript (redacted), in order:

T+0    user      <teammate-message teammate_id="quality-reviewer" summary="Worktree verified, ready for review">
                 Worktree verified at <worktree-path>. WORKTREE OK. Ready to receive tickets.
                 </teammate-message>

                 <teammate-message teammate_id="quality-reviewer">
                 {"type":"idle_notification","from":"quality-reviewer","idleReason":"available"}
                 </teammate-message>

T+3s   assistant TEXT: "Quality-reviewer verified. All 5 agents ready; 3 implementers
                       working. Awaiting DONE signals."

T+3.2s system    stop_hook_summary  (clean, no error)

[no further entries — transcript ends here]
  • Tool-use census on the foreground session over its full lifetime: 18× Bash, 5× Agent, 3× SendMessage, 3× Read, 3× TaskCreate, 1× Grep, 1× ToolSearch, 1× TeamCreate. 0× AskUserQuestion, 0× EnterPlanMode, 0× ExitPlanMode.
  • Sub-agent transcripts continued writing for ~3 minutes after the foreground transcript ended, then stopped abruptly.

Reproduction

Not reliably reproducible. Happens intermittently in workloads that coordinate multiple parallel sub-agents over SendMessage.

Possibly related

  • #16918 (closed as dup of #16871) — same symptom (RangeError stack overflow during AskUserQuestion render after parallel agents completed) on v2.1.1, closed 2026-01-08. The current crash on v2.1.112 may be a regression or a related uncovered code path.

Impact

  • Foreground CLI dies; user loses interactive session.
  • Sub-agent processes are orphaned and continue running for several minutes (related to #20369 / #19045).
  • Any in-flight coordination state is lost.

What should happen

  • The CLI should not crash while idle.
  • If the AskUserQuestion / plan-interview render path is being entered spuriously (no user-facing question pending), entry should be guarded.
  • If a render does fail, the error boundary should report and recover, not recurse.

extent analysis

TL;DR

The likely fix involves addressing the infinite recursion in the tengu_ask_user_question_finish_plan_interview analytics event handling, possibly by adding a guard to prevent spurious entry into the AskUserQuestion render path.

Guidance

  • Investigate the tengu_ask_user_question_finish_plan_interview function to identify the cause of the infinite recursion, focusing on the interaction with xf8(g, i) for image attachment processing.
  • Review the React error boundary and effect re-render loop to ensure proper error handling and recovery mechanisms are in place to prevent recursion.
  • Consider adding a check to prevent the AskUserQuestion render path from being entered when no user-facing question is pending.
  • Examine the sPH and ov functions to understand their roles in the recursion and how they can be modified to break the cycle.

Example

No code snippet can be provided without more context, but the fix might involve adding a conditional check before entering the AskUserQuestion render path, such as:

if (userFacingQuestionPending) {
  // Enter AskUserQuestion render path
} else {
  // Handle or ignore the spurious entry
}

Notes

The issue's intermittent nature and lack of reliable reproduction make it challenging to provide a definitive fix. The provided guidance is based on the information given and may need to be adapted or expanded upon further investigation.

Recommendation

Apply a workaround by adding a guard to prevent spurious entry into the AskUserQuestion render path, as this is the most direct approach to addressing the immediate cause of the crash.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix CLI crash: stack-overflow recursion in AskUserQuestion render path while idle (no question pending) [2 comments, 2 participants]