claude-code - 💡(How to fix) Fix [BUG] claude -r crashes with "UKH is not a function" on session resume [1 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#53284Fetched 2026-04-26 05:19:37
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4

Error Message

ERROR UKH is not a function. (In 'UKH(K)', 'UKH' is undefined) 9248: Error: sandbox required but unavailable: ${j$}

Error Messages/Logs

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

Root Cause

What happens instead: step 4 crashes because onSessionRestored is undefined — the RW4 hook only returns that callback when enabled=true, but the flag is hardcoded to false, so
the process dies before reaching the prompt.

Fix Action

Fix / Workaround

  • Reproduces on every claude -r invocation, regardless of which session is selected.
    • Workaround: launch a fresh session with claude (no -r) and use the in-session /resume slash command — that path works.
    • Root cause appears to be in the REPL hook RW4({ enabled: I, ... }) at cli.js ~line 9247: I is hardcoded false via useMemo(() => false, []), so the destructured
      onSessionRestored callback is undefined. The resume code path then calls it unconditionally as UKH(K) after rehydrating initialMessages, throwing the TypeError.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

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

/$bunfs/root/src/entrypoints/cli.js:9247:5663

9244: ${K.join(`

9245:

9246 )}}var $v5,sv4=1000,qv5=300,Kv5=5000;var FC6=T(()=>{L$();V$();Tp();zb();av4();$$();oN();$v5=(NmH(),S6(kmH))});var KV4={};X$(KV4,{useScheduledTasks:()=>Av5});function

: Av5({isLoading:H,assistantMode:$,setMessages:q}){let K=QD8.useRef(H);K.current=H;let _=B9(),A=F6(),z=Ww();QD8.useEffect(()=>{if(!TZ()||R6())return;let

   f=(M)=>Ez({value:_v5.resolveLoopDefaultFire(M),mode:"prompt",priority:"later",isMeta:!0,workload:SSH}),Y=void 0,O=BC6({onFire:f,onFireTask:(M)=>{if(M.agentId){let           
                                                                                                                                                                                
   w=dr(M.agentId,_.getState().tasks);if(w&&!sI(w.status)){fmH(w.id,M.prompt,z);return}E(`[ScheduledTasks] teammate ${M.agentId} gone, removing orphaned cron                   
                                                                                                                                                                                
   ${M.id}`),l$H([M.id]);return}let D=WB7(M.kind==="loop"?`Claude resuming /loop wakeup (${qV4(new Date)})`:`Running scheduled task (${qV4(new

Date)})`);q((w)=>[...w,D]),f(M.pro
mpt)},isLoading:()=>K.current,assistantMode:$,getJitterConfig:t5H,isKilled:()=>!TZ(),getExtraTasks:$V4&&Y?()=>$V4.getRoutineCronTasks(Z_(),Y):void 0});return

   O.start(),()=>{O.stop()}},[$,q,_.getState,z])}function qV4(H){return H.toLocaleString("en-US",{month:"short",day:"nume

──── (153 lines hidden) ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ser"));yY([]),f4?.abort("user-cancel")}else if(_J.isRemoteMode)J.cancelRequest();else
f4?.abort("user-cancel");pA(null),vvH(f5.current,!0)}let AL$=s$.useCallback(()=>{let
j$=vc$(M7.current,0);if(!j$)return;if(G
(j$.text),nM("prompt"),j$.images.length>0)DL((r$)=>{let _8={...r$};for(let Hq of j$.images)_8[Hq.id]=Hq;return

8})},[G,nM,DL]),zL$={setToolUseConfirmQueue:GK,onCancel:IvH,getConnectionSummary:()=>SD.current?.summary(),onAgentsKilled:()=>F7((j$)=>[...j$,ZB7()]),isMessageSelectorVisib

le:gs||!!Uc,screen:f$,abortSignal:f4?.signal,isExternalLoading:A5,popCommandFromQueue:AL$,isLocalJSXCommand:P8?.isLocalJSXCommand,isInputOverlayActive:E$,inputMode:ff,isInput
Empty:i9};s$.useEffect(()=>{if(h)return;if(LL()>=5&&!ds&&!Fc){if(d("tengu_cost_threshold_reached",{}),AJ(!0),YS$())pKH(!0)}},[S9,ds,Fc]);let
hw8=s$.useCallback(async(j$)=>{let
r$=DH.getState(),{mode:_8,isBypassPermissionsModeAvailable:Hq}=r$.toolPermissionContext;switch(GV$(8,Hq)){case"allow":return!0;case"deny":return!1;case"classify":return
C68(j$.host,j$.port,f5.current,X6.current,r$.toolPermissionContext,new AbortController().signal);case"ask":break}if(yK()&&R
$()){let OK=vQK(),qK=await
VQK(j$.host,OK);return
new
Promise((lK)=>{if(!qK){BA(($q)=>[...$q,{hostPattern:j$,resolvePromise:lK}]);return}EQK({requestId:OK,host:j$.host,resolve:lK}),e(($q)=>({...$q,pendingSandboxRequest:{requ
estId:OK,host:j$.host}}))})}return new Promise((OK)=>{let qK=!1;function lK($q){if(qK)return;qK=!0,OK($q)}BA(($q)=>[...$q,{hostPattern:j$,resolvePromise:lK}]);{let
$q=DH.getState().replBridgePermissionCallbacks;if($q){let Y7=mOH.randomUUID();$q.sendRequest(Y7,yD8,{host:j$.host},mOH.randomUUID(),Allow network connection to ${j$.host}?);let U1=$q.onResponse(Y7,(Lz)=>{U1();let _O=Lz.behavior==="allow";BA((Fw)=>{return
Fw.filter((Uw)=>Uw.hostPattern.host===j$.host).forEach((Uw)=>Uw.resolvePromise(_O)),Fw.filter((Uw)=>Uw.hostPattern.host!==j$.host)});let
NG=pw.current.get(j$.host);if(NG){for(let Fw of
NG)Fw();pw.current.delete(j$.host)}}),iM=()=>{U1(),$q.cancelRequest(Y7)},R9=pw.current.get(j$.host)??[];R9.push(iM),pw.current
.set(j$.host,R9)}}})},[e,DH]);if(s$.useEffect(()=>{let j$=E6.getSandboxUnavailableReason();if(!j$)return;if(E6.isSandboxRequired()){process.stderr.write( 9248: Error: sandbox required but unavailable: ${j$} 9249:+` sandbox.failIfUnavailable is set \u2014 refusing to start without a working sandbox.
9250:

What Should Happen?

● What should happen:

When you run claude -r, the CLI should:

  1. Show a picker of previous sessions (or resume the last one directly).
  2. Load historical messages (initialMessages) from the JSONL transcript.
  3. Restore session context: working directory, agent type, file history, tool state.
  4. Call onSessionRestored(messages) to notify dependent subsystems (remote bridge, telemetry, dedup state) that the session has been rehydrated.
  5. Drop you at the prompt with the transcript visible, ready to continue the conversation.

What happens instead: step 4 crashes because onSessionRestored is undefined — the RW4 hook only returns that callback when enabled=true, but the flag is hardcoded to false, so
the process dies before reaching the prompt.

Expected fix: either RW4 should return a no-op stub when disabled, or the call site should guard with optional chaining: onSessionRestored?.(K).

Error Messages/Logs

Steps to Reproduce

Steps to Reproduce

  1. Have at least one prior Claude Code session recorded for the current project (i.e. a JSONL transcript exists under ~/.claude/projects/<project-slug>/).
  2. From the project directory, run:
    claude -r --dangerously-skip-permissions                                                                                                                                       
    (The --dangerously-skip-permissions flag is not required to trigger the bug — claude -r alone reproduces it.)
  3. Select any previous session from the resume picker (or let it auto-pick if only one exists).

Expected: The CLI loads the transcript and drops me at the prompt, ready to continue the session.

Actual: The process crashes immediately with:

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

/$bunfs/root/src/entrypoints/cli.js:9247:5663

Environment

  • OS: Linux 6.8.0-101-generic (Ubuntu)
  • Shell: bash
  • Claude Code version: <run claude --version and paste here>
  • Install method: <npm global / bun / other>

Notes

  • Reproduces on every claude -r invocation, regardless of which session is selected.
  • Workaround: launch a fresh session with claude (no -r) and use the in-session /resume slash command — that path works.
  • Root cause appears to be in the REPL hook RW4({ enabled: I, ... }) at cli.js ~line 9247: I is hardcoded false via useMemo(() => false, []), so the destructured
    onSessionRestored callback is undefined. The resume code path then calls it unconditionally as UKH(K) after rehydrating initialMessages, throwing the TypeError.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.119

Claude Code Version

2.1.119

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The issue can be fixed by modifying the RW4 hook to return a no-op stub when enabled is false, or by adding optional chaining to the onSessionRestored call site.

Guidance

  • The root cause of the issue is the RW4 hook returning undefined for onSessionRestored when enabled is false.
  • To fix this, the RW4 hook should be modified to return a no-op stub for onSessionRestored when enabled is false.
  • Alternatively, the call site can be modified to use optional chaining, e.g., onSessionRestored?.(K).
  • The issue is reproducible by running claude -r with at least one prior Claude Code session recorded.

Example

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

// Alternatively, modify the call site to use optional chaining
onSessionRestored?.(K);

Notes

  • The issue is a regression, and it worked in a previous version (2.1.119).
  • The fix should be applied to the cli.js file, specifically to the RW4 hook.

Recommendation

Apply the workaround by modifying the RW4 hook to return a no-op stub when enabled is false, or by adding optional chaining to the onSessionRestored call site. This will fix the issue and allow the claude -r command to work as expected.

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 [BUG] claude -r crashes with "UKH is not a function" on session resume [1 participants]