claude-code - 💡(How to fix) Fix `claude -r` crashes immediately: `g9H is not a function` (onSessionRestored undefined) [1 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#53103Fetched 2026-04-25 06:12:16
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
2
Author
Timeline (top)
cross-referenced ×3commented ×1subscribed ×1

Running claude -r (resume) crashes immediately with g9H is not a function before the TUI renders. Starting claude normally and using /resume from inside the UI works fine.

Error Message

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)
/$bunfs/root/src/entrypoints/cli.js:9251:5663

Root Cause

This path is hit on claude -r because resume seeds initialMessages. The in-UI /resume flow goes through a different code path and is unaffected.

Fix Action

Workaround

Start claude without -r, then use /resume to pick the session.

Code Example

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)
/$bunfs/root/src/entrypoints/cli.js:9251:5663

---

- <anonymous> (cli.js:9251:5663)
- WC (cli.js:492:63749)
- pj (cli.js:492:76948)
- fT (cli.js:492:76827)
...

---

let { onBeforeQuery: F9H, onTurnComplete: ZLH, onSessionRestored: g9H, render: aM_, ownsInput: LLH } = FXK({ enabled: S, ... })

---

if (K && K.length > 0) {
  HP_(K, K8());
  hY8({ ... });
  tC8(K);
  UQ(K);
  sYH.current.current = xz_(K, g8);
  g9H(K);   // crashes here
}
RAW_BUFFERClick to expand / collapse

Summary

Running claude -r (resume) crashes immediately with g9H is not a function before the TUI renders. Starting claude normally and using /resume from inside the UI works fine.

Environment

  • Claude Code: 2.1.120
  • OS: macOS 15.6 (Darwin 24.6.0)
  • Shell: zsh

Repro

  1. cd into any project directory with prior sessions
  2. Run claude -r
  3. Crash before UI renders

Error

ERROR  g9H is not a function. (In 'g9H(K)', 'g9H' is undefined)
/$bunfs/root/src/entrypoints/cli.js:9251:5663

Stack (top frames)

- <anonymous> (cli.js:9251:5663)
- WC (cli.js:492:63749)
- pj (cli.js:492:76948)
- fT (cli.js:492:76827)
...

Likely cause

At cli.js:9251, the REPL destructures from FXK({ enabled: S, ... }):

let { onBeforeQuery: F9H, onTurnComplete: ZLH, onSessionRestored: g9H, render: aM_, ownsInput: LLH } = FXK({ enabled: S, ... })

S is hardcoded to false (useMemo(() => false, [])), so FXK runs the disabled path and returns an object without onSessionRestored. A subsequent effect calls g9H(K) unconditionally when initialMessages is present:

if (K && K.length > 0) {
  HP_(K, K8());
  hY8({ ... });
  tC8(K);
  UQ(K);
  sYH.current.current = xz_(K, g8);
  g9H(K);   // crashes here
}

This path is hit on claude -r because resume seeds initialMessages. The in-UI /resume flow goes through a different code path and is unaffected.

Workaround

Start claude without -r, then use /resume to pick the session.

extent analysis

TL;DR

The most likely fix is to modify the code to conditionally call g9H(K) only when g9H is defined.

Guidance

  • Verify that g9H is indeed undefined when running claude -r by adding a console log or debugger statement before the line that calls g9H(K).
  • Check the FXK function to see why it returns an object without onSessionRestored when S is false.
  • Consider adding a null check for g9H before calling it, e.g., if (g9H) g9H(K).
  • Investigate why the in-UI /resume flow does not hit the same code path as claude -r.

Example

if (K && K.length > 0) {
  // ...
  if (g9H) { // add null check
    g9H(K);
  }
}

Notes

The provided workaround of starting claude without -r and using /resume suggests that the issue is specific to the claude -r flow.

Recommendation

Apply workaround: Start claude without -r, then use /resume to pick the session, as this avoids the code path that causes 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 `claude -r` crashes immediately: `g9H is not a function` (onSessionRestored undefined) [1 comments, 2 participants]