[BUG] Cannot read properties of undefined (reading 'trim') when resuming session
Resolved 💬 21 comments Opened Jan 7, 2026 by marcondesmacaneiro Closed Apr 8, 2026
Bug Description
When attempting to resume a previous session using the interactive picker or --resume flag, Claude Code crashes with the following error:
ERROR Cannot read properties of undefined (reading 'trim')
file:///Users/marcondesmacaneiro/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2613:4942
- vA7 (file:///Users/marcondesmacaneiro/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2613:4942)
- h5 (file:///Users/marcondesmacaneiro/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:20693)
- IY (file:///Users/marcondesmacaneiro/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:39057)
- ss (file:///Users/marcondesmacaneiro/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:49664)
- MJ (file:///Users/marcondesmacaneiro/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:85801)
- Xf (file:///Users/marcondesmacaneiro/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:84781)
- u_ (file:///Users/marcondesmacaneiro/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:84606)
- cS (file:///Users/marcondesmacaneiro/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:81426)
- j0 (file:///Users/marcondesmacaneiro/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:6360)
- F1 (file:///Users/marcondesmacaneiro/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:252:4874)
Steps to Reproduce
- Have existing sessions in Claude Code history
- Run
claudeand use the interactive picker to select a previous session to resume - Or run
claude --resumeand select a session - Error occurs immediately when trying to resume
Environment
- Claude Code Version: 2.1.1 (also occurred on 2.0.76)
- Node.js Version: v22.17.0
- OS: macOS (Darwin 25.1.0)
- Shell: zsh
Investigation Done
- Session file (
.jsonl) is valid JSON - no corrupted lines - All summary entries in the session file have valid string content (not null or empty)
- The issue persists even after upgrading from 2.0.76 to 2.1.1
Expected Behavior
Session should resume normally without crashing.
Additional Context
The session being resumed had 73 messages and the .jsonl file is ~927KB. The file passes JSON validation for all lines.
21 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Got same problem.
I ma using docker container with:
OS:
debian:bookwormShell:
bashClaude code version:
node2.0.76 (Claude Code)nodejs version:
v22.21.0SAME PROBLEM, using the npm client, not the "native" one. If you all are using Claude Code, to develop Claude Code, then you all are not proving the greatness of Claude Code. Just sayin.
Same on 2.1.22.
---
## Environment
## Description
When trying to resume a session that was interrupted (Ctrl+C), Claude Code crashes with a trim() error on undefined.
## Steps to reproduce
claude --continue## Reproducibility
Always - happens every time when trying to resume an interrupted session.
## Error
```
ERROR Cannot read properties of undefined (reading 'trim')
file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2722:6198
```
## Expected behavior
Session should resume successfully, or provide a clear error message if the session data is corrupted.
## Workaround
Deleting session files in
~/.claude/projects/*/sessions/allows starting fresh.Likely same root cause as #27219 — the TUI renderer calls
.trim()on an undefined field when replaying hook event records (hook_success,hook_blocking_error, etc.) during--resume. Root cause analysis and stack trace from the Bun bundle there.Same here
windows 10
VS Code:1.111.0
Claude Code for VS Code:2.1.74
The claude code cli runs okay
<img width="472" height="339" alt="Image" src="https://github.com/user-attachments/assets/deffe724-8dcf-4a06-980c-e4d0287a4df0" />
same here,
mac-os
VS Code:1.111.1
Claude Code for VS Code:2.1.74
Hi, @huahanqi @xhrg . I have the same issue in vscode.
Bug detail in Webview Developer Tool's console
~/.vscode/extensions/anthropic.claude-code-<version>-<platform>/webview/index.js
function lB1($){return!$.text.trim()||$.text.trim()===cB1}
function lB1($){return!($.text||"").trim()||($.text||"").trim()===cB1}
<img width="1040" height="642" alt="Image" src="https://github.com/user-attachments/assets/e46a08bd-fd44-4ac2-a1c4-642f8ac13c05" />
face a similar :
Error rendering content: Cannot read properties of undefined (reading 'trim')Steps: When total project context (multiple sessions) is too long, sending a new request triggers the error (not when resuming a session).
Env: Claude Code (npm)lastest, Windows11
@YukunR That's fine, thank you very much
On macos, claude code version: anthropic.claude-code-2.1.76-darwin-arm64
the function's name is different, it's called: aB1
Find aB1 in your extension's webview/index.js:
Replace (line 1439 in my file):
With:
<img width="350" height="210" alt="Image" src="https://github.com/user-attachments/assets/dbfeb715-9747-4024-9c98-632078f78390" />持续出现,太烦人了,版本已经是2.1.79了。
same here
Claude Code 2.1.79
VScode 1.112.0
<img width="743" height="331" alt="Image" src="https://github.com/user-attachments/assets/2b3bf9d9-c04b-4507-9eb5-c857e9eb5324" />
换成哪个版本都出现
og.ts:450 WARN SettingsEditor2: Settings not included in settingsLayout.ts: extensions.requestTimeout, github.copilot.chat.agent.terminal.allowList, github.copilot.chat.agent.terminal.denyList, terminal.integrated.developer.devMode, terminal.integrated.developer.ptyHost.latency, terminal.integrated.developer.ptyHost.startupDelay, terminal.integrated.enableKittyKeyboardProtocol, terminal.integrated.enableWin32InputMode, chat.autopilot.enabled, chat.autoReply, chat.contextUsage.enabled, chat.customizationsMenu.enabled, chat.experimentalSessionsWindowOverride, chat.exploreAgent.defaultModel, chat.growthNotification.enabled, chat.pluginLocations, chat.plugins.enabled, chat.plugins.marketplaces, chat.statusWidget.anonymous, chat.upvoteAnimation, chat.useClaudeHooks, chat.useCustomAgentHooks, accessibility.signals.chatResponseReceived, accessibility.signals.chatUserActionRequired
warn @ log.ts:450
warn @ log.ts:559
warn @ logService.ts:47
onConfigUpdate @ settingsEditor2.ts:1399
setInput @ settingsEditor2.ts:509
log.ts:440 INFO Started local extension host with pid 14052.
console.ts:139 [Extension Host] Created lock file at C:\Users\green\.claude\ide\32030.lock
console.ts:139 [Extension Host] Set CLAUDE_CODE_SSE_PORT=32030 in terminal environment (in-memory)
webviewElement.ts:411 Unrecognized feature: 'local-network-access'.
_createElement @ webviewElement.ts:411
cre @ webviewElement.ts:190
l2e @ webviewElement.ts:62
_createInstance @ instantiationService.ts:162
createInstance @ instantiationService.ts:128
createWebviewElement @ webviewService.ts:13
_show @ overlayWebview.ts:234
claim @ overlayWebview.ts:145
claim @ webviewEditorInput.ts:165
claimWebview @ webviewEditor.ts:173
setInput @ webviewEditor.ts:164
webviewElement.ts:491 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
mountTo @ webviewElement.ts:491
_show @ overlayWebview.ts:259
claim @ overlayWebview.ts:145
claim @ webviewEditorInput.ts:165
claimWebview @ webviewEditor.ts:173
setInput @ webviewEditor.ts:164
index.html?id=28dbc809-d9e9-4b21-89e0-25bb421f7c0e&parentId=1&origin=351b6eec-2f3a-4e39-ab57-7a6ebe8d78b9&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1060 Unrecognized feature: 'local-network-access'.
(anonymous) @ index.html?id=28dbc809-d9e9-4b21-89e0-25bb421f7c0e&parentId=1&origin=351b6eec-2f3a-4e39-ab57-7a6ebe8d78b9&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1060
index.html?id=28dbc809-d9e9-4b21-89e0-25bb421f7c0e&parentId=1&origin=351b6eec-2f3a-4e39-ab57-7a6ebe…:1 Loading the font 'data:font/ttf;base64,AAEAAAALAIAAAwAwR1NVQiCLJXoAAAE4AAAAVE9TLzI3T0tHAAABjAAAAGBjbWFwQ5s/ewAACSQAABreZ2x5ZvJtKHkAACekAAD3FGhlYWRYl6BTAAAA4AAAADZoaGVhAlsC+QAAALwAAAAkaG10eBxB//oAAAHsAAAHOGxvY2EFi8dWAAAkBAAAA55tYXhwAu8BgQAAARgAAAAgbmFtZZP3uUsAAR64AAAB+HBvc3RjGEbCAAEgsAAAGSQAAQAAASwAAAAAASz////+AS4AAQAAAAAAAAAAAAAAAAAAAc4AAQAAAAEAAFT7+XFfDzz1AAsBLAAAAAB8JbCAAAAAAHwlsID////9AS4BLQAAAAgAAgAAAAAAAAABAAABzgF1ABcAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKADAAPgACREZMVAAObGF0bgAaAAQAAAAAAAAAAQAAAAQAAAAAAAAAAQAAAAFsaWdhAA...h0C3RyaWFuZ2xlLXVwB3R3aXR0ZXISdHlwZS1oaWVyYXJjaHktc3ViFHR5cGUtaGllcmFyY2h5LXN1cGVyDnR5cGUtaGllcmFyY2h5BnVuZm9sZBN1bmdyb3VwLWJ5LXJlZi10eXBlBnVubG9jawZ1bm11dGUKdW52ZXJpZmllZA52YXJpYWJsZS1ncm91cA92ZXJpZmllZC1maWxsZWQIdmVyaWZpZWQIdmVyc2lvbnMJdm0tYWN0aXZlCnZtLWNvbm5lY3QKdm0tb3V0bGluZQp2bS1ydW5uaW5nAnZtAnZyD3ZzY29kZS1pbnNpZGVycwZ2c2NvZGUEd2FuZAd3YXJuaW5nBXdhdGNoCndoaXRlc3BhY2UKd2hvbGUtd29yZAZ3aW5kb3cJd29yZC13cmFwEXdvcmtzcGFjZS10cnVzdGVkEXdvcmtzcGFjZS11bmtub3duE3dvcmtzcGFjZS11bnRydXN0ZWQHem9vbS1pbgh6b29tLW91dAAA' violates the following Content Security Policy directive: "font-src 'self' https://.vscode-cdn.net". The action has been blocked.
log.ts:440 INFO Settings Sync: Account status changed from uninitialized to unavailable
log.ts:440 INFO MCP Registry configured: https://api.mcp.github.com
log.ts:440 INFO [perf] Render performance baseline is 16ms
log.ts:440 INFO Auto updating outdated extensions. anthropic.claude-code
index.js:8 TypeError: Cannot read properties of undefined (reading 'trim')
at Uj0 (index.js:1439:25598)
at index.js:1439:27010
at Array.every (<anonymous>)
at get isEmpty (index.js:1439:26974)
at LN1 (index.js:2040:19538)
at index.js:2040:13773
at Array.map (<anonymous>)
at index.js:2040:13742
at Array.map (<anonymous>)
at yo0 (index.js:2040:13709)
br @ index.js:8
Q.componentDidCatch.Z.callback @ index.js:8
WU0 @ index.js:6
bU0 @ index.js:8
OV0 @ index.js:8
Z11 @ index.js:8
q11 @ index.js:8
MH @ index.js:8
xU0 @ index.js:8
IV @ index.js:6
(anonymous) @ index.js:8
postMessage
(anonymous) @ index.html?id=28dbc809-d9e9-4b21-89e0-25bb421f7c0e&parentId=1&origin=351b6eec-2f3a-4e39-ab57-7a6ebe8d78b9&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1282
HostMessaging.channel.port1.onmessage @ index.html?id=28dbc809-d9e9-4b21-89e0-25bb421f7c0e&parentId=1&origin=351b6eec-2f3a-4e39-ab57-7a6ebe8d78b9&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:342
index.js:2039 Error rendering content: TypeError: Cannot read properties of undefined (reading 'trim')
at Uj0 (index.js:1439:25598)
at index.js:1439:27010
at Array.every (<anonymous>)
at get isEmpty (index.js:1439:26974)
at LN1 (index.js:2040:19538)
at index.js:2040:13773
at Array.map (<anonymous>)
at index.js:2040:13742
at Array.map (<anonymous>)
at yo0 (index.js:2040:13709) {componentStack: '\n at yo0 (https://file+.vscode-resource.vscode-…ode-2.1.49-win32-x64/webview/index.js:2039:38142)'}
The minified function names may differ across platforms due to differences in the build environment or AST transformations.
In practice, you can fix this issue by replacing
$.text.trim()with($.text || "").trim()at the corresponding error line (usually line 1439) in:~/.vscode/extensions/anthropic.claude-code-<version>-<platform>/webview/index.jsthanks,it helps.
Yes, there are platform differences — I noticed this when applying the fix. On Windows (
anthropic.claude-code-2.1.79-win32-x64), it'seB1/tB1in myindex.js, notlB1/cB1oraB1/sB1as mentioned above. Everything else is the same.<img width="507" height="238" alt="Image" src="https://github.com/user-attachments/assets/09a28ed6-2400-4253-8ebe-0ce75781b935" />
same issue exists with claude 2.1.92 aand 2.1.81, both linux and macos !
IGNORE THIS COMMENT - testing tool availability
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.