Crash on --resume in v2.1.120: "UKH is not a function" (onSessionRestored undefined when initialMessages is non-empty)
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
- Have at least one prior session for the current project so
--resumehas something to load. - Run
claude --resume. - Pick any session.
- 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-oponSessionRestored, 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.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗