claude-code - 💡(How to fix) Fix Crash on --resume in v2.1.120: "UKH is not a function" (onSessionRestored undefined when initialMessages is non-empty) [2 comments, 3 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#53101Fetched 2026-04-25 06:12:19
View on GitHub
Comments
2
Participants
3
Timeline
7
Reactions
0
Timeline (top)
cross-referenced ×3commented ×2mentioned ×1subscribed ×1

On Claude Code v2.1.120, running claude --resume reliably crashes with:

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

Plain claude (no --resume) works fine. The underlying bug looks like it would also fire whenever initialMessages is non-empty at REPL mount.

Error Message

ERROR UKH is not a function. (In 'UKH(K)', 'UKH' is undefined)

Root Cause

Root cause (from the minified bundle)

In the REPL component (QC6), around line 9247, there is:

Fix Action

Fix / Workaround

Workarounds for other users hitting this

  • Downgrade to 2.1.119 (or earlier) until a fix ships.
  • Avoid --resume; start fresh and re-prompt.

Code Example

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

---

- <anonymous> (cli.js:9247:5663)
- JR (cli.js:492:63749)
- Bw (cli.js:492:76948)
- Xz (cli.js:492:76827)
- Bw (cli.js:492:76926)
- Xz (cli.js:492:76827)
- Bw (cli.js:492:77745)
...

---

let { onBeforeQuery: FKH, onTurnComplete: vvH, onSessionRestored: UKH,
      render: sJ$, ownsInput: VvH } =
  RW4({ enabled: I, setMessages: F7, setInputValue: G_,
        setToolJSX: oK, resultDedupState: RF.current });

---

s$.useEffect(() => {
  if (K && K.length > 0) {
    $L$(K, K6());
    yO6({ abortController: new AbortController, taskRegistry: OH });
    eR6(K);
    Bc(K);
    tOH.current.current = u3$(K, U6);
    UKH(K);                       // <-- crash: UKH is undefined
  }
}, []);
RAW_BUFFERClick to expand / collapse

Summary

On Claude Code v2.1.120, running claude --resume reliably crashes with:

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

Plain claude (no --resume) works fine. The underlying bug looks like it would also fire whenever initialMessages is non-empty at REPL mount.

Environment

  • Claude Code: 2.1.120 (native binary at /root/.local/share/claude/versions/2.1.120)
  • Platform: Linux 6.6.87.2-microsoft-standard-WSL2 (WSL2)
  • Shell: zsh
  • Runtime: bundled (bun single-file executable)
  • Earlier versions still on disk that I have NOT verified yet: 2.1.114, 2.1.118, 2.1.119

Reproduction

  1. Have at least one prior session for the current project so --resume has something to load.
  2. Run claude --resume.
  3. Pick any session.
  4. Crash is immediate, before the REPL renders.

Stack (top frames)

- <anonymous> (cli.js:9247:5663)
- JR (cli.js:492:63749)
- Bw (cli.js:492:76948)
- Xz (cli.js:492:76827)
- Bw (cli.js:492:76926)
- Xz (cli.js:492:76827)
- Bw (cli.js:492:77745)
...

Root cause (from the minified bundle)

In the REPL component (QC6), around line 9247, there is:

let { onBeforeQuery: FKH, onTurnComplete: vvH, onSessionRestored: UKH,
      render: sJ$, ownsInput: VvH } =
  RW4({ enabled: I, setMessages: F7, setInputValue: G_,
        setToolJSX: oK, resultDedupState: RF.current });

where I = s$.useMemo(() => !1, []) -- i.e. always false.

Then later:

s$.useEffect(() => {
  if (K && K.length > 0) {
    $L$(K, K6());
    yO6({ abortController: new AbortController, taskRegistry: OH });
    eR6(K);
    Bc(K);
    tOH.current.current = u3$(K, U6);
    UKH(K);                       // <-- crash: UKH is undefined
  }
}, []);

When enabled is false, RW4 apparently returns an object that does not include onSessionRestored, so UKH is destructured to undefined. But the effect still calls UKH(K) unconditionally whenever initialMessages (K) is non-empty -- which is exactly the --resume path.

Without --resume, K is empty, the if branch is skipped, and the bug is hidden.

Suggested fix

Either:

  • have RW4({ enabled: false, ... }) return a no-op onSessionRestored, or
  • guard the call site: if (UKH) UKH(K);

The first 是 safer (keeps the contract uniform across enabled states).

Workarounds for other users hitting this

  • Downgrade to 2.1.119 (or earlier) until a fix ships.
  • Avoid --resume; start fresh and re-prompt.

extent analysis

TL;DR

The most likely fix is to modify the RW4 function to return a no-op onSessionRestored when enabled is false, or guard the call site to check if UKH is defined before calling it.

Guidance

  • The issue is caused by UKH being undefined when enabled is false, which happens when using the --resume flag.
  • To verify, check if the issue is resolved by downgrading to version 2.1.119 or earlier, or by avoiding the use of --resume.
  • A potential workaround is to modify the code to include a no-op onSessionRestored when enabled is false, or to add a check before calling UKH(K) to ensure it is defined.
  • The suggested fix is to either modify the RW4 function or guard the call site, with the first option being safer to maintain a uniform contract across enabled states.

Example

// Modified RW4 function to return a no-op onSessionRestored
function RW4(options) {
  // ...
  if (!options.enabled) {
    return {
      // ...
      onSessionRestored: () => {}, // no-op
    };
  }
  // ...
}

// Guarding the call site
if (UKH) {
  UKH(K);
}

Notes

The provided fix and workarounds are based on the analysis of the issue and may not be exhaustive. It is recommended to test and verify the solutions in the specific environment and version of Claude Code being used.

Recommendation

Apply the suggested fix by modifying the RW4 function to return a no-op onSessionRestored when enabled is false, as it is a safer and more uniform solution.

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 Crash on --resume in v2.1.120: "UKH is not a function" (onSessionRestored undefined when initialMessages is non-empty) [2 comments, 3 participants]