claude-code - 💡(How to fix) Fix TypeError: onSessionRestored is undefined when resuming sessions in 2.1.120 [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#53113Fetched 2026-04-25 06:12:01
View on GitHub
Comments
2
Participants
2
Timeline
9
Reactions
0
Author
Timeline (top)
labeled ×6commented ×2closed ×1

In Claude Code 2.1.120, running claude --continue (or --resume) crashes the TUI with:

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

at cli.js:9247:5663.

The minified variable UKH is destructured from a session-config object as onSessionRestored. When the TUI mounts and tries to invoke that callback, it's missing → crash.

Error Message

ERROR UKH is not a function. (In 'UKH(K)', 'UKH' is undefined) The error appears immediately on TUI mount. The session UI never becomes interactive. The stack trace shows lines 9248–9250 of the bundle, which happen to contain the template literal source for the sandbox required but unavailable error. That made it initially look like a sandbox issue. It is not — getSandboxUnavailableReason() is in the same useEffect body, but never executes because UKH(K) throws first.

Root Cause

The stack trace shows lines 9248–9250 of the bundle, which happen to contain the template literal source for the sandbox required but unavailable error. That made it initially look like a sandbox issue. It is not — getSandboxUnavailableReason() is in the same useEffect body, but never executes because UKH(K) throws first.

Fix Action

Workaround

Pin to 2.1.119:

ln -sfn ~/.local/share/claude/versions/2.1.119 ~/.local/bin/claude

Code Example

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

---

# In any directory with an existing Claude Code session history
claude --continue

---

({onBeforeQuery: FKH, onTurnComplete: vvH, onSessionRestored: UKH, ...})
// ...
c(K), tOH.current.current = u3$(K, U6), UKH(K)

---

ln -sfn ~/.local/share/claude/versions/2.1.119 ~/.local/bin/claude
RAW_BUFFERClick to expand / collapse

Summary

In Claude Code 2.1.120, running claude --continue (or --resume) crashes the TUI with:

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

at cli.js:9247:5663.

The minified variable UKH is destructured from a session-config object as onSessionRestored. When the TUI mounts and tries to invoke that callback, it's missing → crash.

Repro

# In any directory with an existing Claude Code session history
claude --continue

The error appears immediately on TUI mount. The session UI never becomes interactive.

Confusing aspect

The stack trace shows lines 9248–9250 of the bundle, which happen to contain the template literal source for the sandbox required but unavailable error. That made it initially look like a sandbox issue. It is not — getSandboxUnavailableReason() is in the same useEffect body, but never executes because UKH(K) throws first.

Surrounding source (relevant part of the same useEffect):

({onBeforeQuery: FKH, onTurnComplete: vvH, onSessionRestored: UKH, ...})
// ...
c(K), tOH.current.current = u3$(K, U6), UKH(K)

onSessionRestored is being destructured from a config object that doesn't always provide it.

Versions tested

  • 2.1.119: claude --continue works correctly. Session resumes, TUI loads with the conversation banner.
  • 2.1.120: crash above on every --continue / --resume of an existing session.

Confirmed by symlinking ~/.local/bin/claude to each version and re-running the same command in the same directory.

Workaround

Pin to 2.1.119:

ln -sfn ~/.local/share/claude/versions/2.1.119 ~/.local/bin/claude

Environment

  • OS: Ubuntu 22.04
  • Shell: zsh (login shell -l)
  • Claude Code version: 2.1.120 (2.1.119 last working)
  • No sandbox config in any settings layer

Suggested fix

Either provide a default no-op for onSessionRestored, or guard the call with UKH?.(K) / if (UKH) UKH(K).

extent analysis

TL;DR

The issue can be fixed by providing a default no-op for onSessionRestored or guarding the call with UKH?.(K) to prevent the crash when UKH is undefined.

Guidance

  • Verify that the onSessionRestored property is being destructured from a session-config object and that it's missing in the current version (2.1.120).
  • Check the surrounding source code to ensure that UKH is not being redefined or overridden elsewhere in the useEffect body.
  • Consider adding a default value for onSessionRestored to prevent the crash, such as onSessionRestored: () => {}.
  • Alternatively, guard the call to UKH with UKH?.(K) to ensure it's only called when UKH is defined.

Example

// Provide a default no-op for onSessionRestored
({onBeforeQuery: FKH, onTurnComplete: vvH, onSessionRestored: UKH = () => {}, ...})

// or guard the call with UKH?.(K)
UKH?.(K)

Notes

The issue seems to be specific to version 2.1.120, and pinning to 2.1.119 provides a temporary workaround. However, a proper fix should be implemented to prevent the crash in the current version.

Recommendation

Apply the workaround by providing a default no-op for onSessionRestored or guarding the call with UKH?.(K), as this will prevent the crash and allow the TUI to mount correctly.

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 TypeError: onSessionRestored is undefined when resuming sessions in 2.1.120 [2 comments, 2 participants]