claude-code - 💡(How to fix) Fix Resume crashes with "g9H is not a function" — REPL onSessionRestored undefined in 2.1.120 [11 comments, 9 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#53041Fetched 2026-04-25 06:13:58
View on GitHub
Comments
11
Participants
9
Timeline
44
Reactions
16
Assignees
Timeline (top)
cross-referenced ×17commented ×11subscribed ×7labeled ×5

On 2.1.120, opening a prior session interactively via claude -r <session-id> (or --resume) crashes on mount with:

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

Print mode (claude -p --resume <id> "…") works fine against the same session file, so the session data is healthy — the bug is purely in the interactive REPL mount path.

Error Message

Error: sandbox required but unavailable: <reason>

  • sandbox.failIfUnavailable is set — refusing to start without a working sandbox.

Root Cause

On 2.1.120, opening a prior session interactively via claude -r <session-id> (or --resume) crashes on mount with:

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

Print mode (claude -p --resume <id> "…") works fine against the same session file, so the session data is healthy — the bug is purely in the interactive REPL mount path.

Fix Action

Workaround

claude -p --resume <id> "…" works — print mode does not mount the REPL, so the broken effect never runs.

Code Example

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

---

claude -r <any-session-id-with-messages>
# also:
claude --dangerously-skip-permissions -r <same-id>

---

let S = s_.useMemo(() => !1, []);        // hardcoded false
let { onBeforeQuery: F9H,
      onTurnComplete: ZLH,
      onSessionRestored: g9H,            // <- undefined
      render: aM_,
      ownsInput: LLH }
    = FXK({ enabled: S, setMessages: F7, ... });

s_.useEffect(() => {
  if (K && K.length > 0) {
    HP_(K, K8()),
    hY8({ abortController: new AbortController, taskRegistry: YH }),
    tC8(K), UQ(K),
    sYH.current.current = xz_(K, g8),
    g9H(K);                              // <- TypeError here
  }
}, []);

---

Error: sandbox required but unavailable: <reason>
  + sandbox.failIfUnavailable is set — refusing to start without a working sandbox.
RAW_BUFFERClick to expand / collapse

Summary

On 2.1.120, opening a prior session interactively via claude -r <session-id> (or --resume) crashes on mount with:

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

Print mode (claude -p --resume <id> "…") works fine against the same session file, so the session data is healthy — the bug is purely in the interactive REPL mount path.

Environment

  • Claude Code 2.1.120 (installed at ~/.local/share/claude/versions/2.1.120)
  • macOS (Darwin 25.3.0)
  • Session was written progressively by 2.1.108 → 2.1.112 → 2.1.113; crash appears only after upgrading to 2.1.120

Repro

claude -r <any-session-id-with-messages>
# also:
claude --dangerously-skip-permissions -r <same-id>

Reproduces with and without --channels plugin flags, so plugins are not the trigger.

Diagnosis from the minified bundle

Inside the REPL component Ub8, which receives initialMessages as K:

let S = s_.useMemo(() => !1, []);        // hardcoded false
let { onBeforeQuery: F9H,
      onTurnComplete: ZLH,
      onSessionRestored: g9H,            // <- undefined
      render: aM_,
      ownsInput: LLH }
    = FXK({ enabled: S, setMessages: F7, ... });

s_.useEffect(() => {
  if (K && K.length > 0) {
    HP_(K, K8()),
    hY8({ abortController: new AbortController, taskRegistry: YH }),
    tC8(K), UQ(K),
    sYH.current.current = xz_(K, g8),
    g9H(K);                              // <- TypeError here
  }
}, []);

FXK({enabled: false, ...}) returns an object that does not include onSessionRestored; destructuring yields undefined; the mount effect invokes it unconditionally whenever the resumed session has any messages. Appears to fire on every interactive resume of a non-empty session.

Workaround

claude -p --resume <id> "…" works — print mode does not mount the REPL, so the broken effect never runs.

Suggested fix

Either:

  • FXK's enabled: false branch should return a no-op onSessionRestored, or
  • The mount effect should guard the call: g9H?.(K).

Adjacent issue (lower priority)

If g9H is bypassed (e.g. by truncating the session so initialMessages is empty), a different mount effect fires and prints:

Error: sandbox required but unavailable: <reason>
  + sandbox.failIfUnavailable is set — refusing to start without a working sandbox.

sandbox.failIfUnavailable is not set in any of my settings files (user, user-local, project, project-local). It looks like --dangerously-skip-permissions implicitly sets isSandboxRequired() to true. That may be intentional defense-in-depth, but the error message blames a user setting that the user didn't set, which is misleading.

extent analysis

TL;DR

The issue can be fixed by modifying the FXK function to return a no-op onSessionRestored when enabled is false, or by guarding the call to g9H with g9H?.(K).

Guidance

  • Verify that the issue is indeed caused by the g9H function being undefined by checking the FXK function's return value when enabled is false.
  • Consider implementing a temporary workaround by using print mode (claude -p --resume <id> "…") instead of interactive mode.
  • To fix the issue, update the FXK function to return an object with a no-op onSessionRestored function when enabled is false, or modify the mount effect to use g9H?.(K) instead of g9H(K).
  • Be aware of the adjacent issue related to sandbox.failIfUnavailable and consider investigating why --dangerously-skip-permissions implicitly sets isSandboxRequired() to true.

Example

// Modified mount effect with guarded call to g9H
s_.useEffect(() => {
  if (K && K.length > 0) {
    // ...
    g9H?.(K); // Guarded call to g9H
  }
}, []);

Notes

The provided diagnosis and suggested fix are based on the assumption that the issue is caused by the g9H function being undefined. However, the root cause of the issue may be more complex and require further investigation.

Recommendation

Apply the workaround by using print mode (claude -p --resume <id> "…") until a permanent fix is available, as it does not trigger the broken mount effect.

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 Resume crashes with "g9H is not a function" — REPL onSessionRestored undefined in 2.1.120 [11 comments, 9 participants]