[BUG] sandbox Claude Code crashes and OOM-killed by kernel when node_modules exists in project directory
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code crashes and is killed by the Linux OOM killer when node_modules/ is present in a pnpm workspace monorepo. The process balloons to ~25GB RSS and ~119GB virtual memory on a 32GB machine until the kernel terminates it.
Kernel log evidence:
Feb 23 11:21:57 kernel: Out of memory: Killed process 91642 (claude) total-vm:119777372kB, anon-rss:25049716kB, file-rss:160kB, shmem-rss:0kB, UID:1000 pgtables:59580kB oom_score_adj:0
This happens both when:
- Starting Claude Code in a project that already has
node_modules/ - Running
pnpm installduring an active session (in a separate terminal)
The Claude Code debug logs (~/.claude/debug/) show no errors — the process simply stops logging as the event loop becomes blocked, then the OOM killer terminates it.
Mitigations attempted with no effect:
.claudeignorewithnode_modules.gitignorewithnode_modules+respectGitignore: truepermissions.denywithRead(./node_modules/**)in project.claude/settings.json
What Should Happen?
Claude Code should not crash after if node_modules/ exist, or ignore node_modules/ for file watching purposes, consistent with .gitignore and .claudeignore patterns. The file watcher should not process directories that are excluded by these ignore files.
Error Messages/Logs
# OOM kill from journalctl:
Feb 23 11:21:57 kernel: Out of memory: Killed process 91642 (claude) total-vm:119777372kB, anon-rss:25049716kB, file-rss:160kB, shmem-rss:0kB, UID:1000 pgtables:59580kB oom_score_adj:0
Steps to Reproduce
- Clone a Node.js/TypeScript project with dependencies (pnpm workspace monorepo in this case)
- Ensure
.gitignoreand.claudeignoreboth containnode_modules - Run
pnpm installto createnode_modules/ - Run
claude— session hangs or becomes unresponsive - Alternative: start
claudefirst, then runpnpm installin another terminal — same result
Claude Model: claude-opus-4-6
Is this a regression?: Unknown — issue has been present since at least version 2.1.50
Claude Code Version: 2.1.50 (Claude Code)
Platform: Anthropic API (direct)
Operating System: Linux 6.8.0-94-generic x86_64 (Ubuntu 22.04)
Terminal/Shell: zsh (xterm-256color)
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.50
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
- RAM: 32GB + 8GB swap
- Node: v18.20.7
- pnpm: 10.13.1
- inotify max_user_watches: 1048576
- inotify max_user_instances: 1024
- Sandbox: enabled
- MCP servers: 1 custom project MCP server + context7
- Hooks: SessionStart, PreToolUse (Bash), PostToolUse (Edit|Write), Notification
- Plugins: 4 enabled (code-simplifier, security-guidance, building-secure-contracts, solidity-function-audit-team)
<details><summary>~/.claude/settings.json (global)</summary>
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"respectGitignore": true,
"cleanupPeriodDays": 7,
"env": {
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1",
"CLAUDE_CODE_SUBAGENT_MODEL": "sonnet",
"ENABLE_TOOL_SEARCH": "auto:5",
"DISABLE_TELEMETRY": "1",
"DISABLE_ERROR_REPORTING": "1",
"CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY": "1"
},
"includeCoAuthoredBy": false,
"permissions": {
"allow": [
"Bash(forge build)", "Bash(forge test *)",
"Bash(git log *)", "Bash(git status *)", "Bash(git diff *)",
"Bash(git show *)", "Bash(git branch *)", "Bash(git remote *)",
"WebFetch", "WebSearch"
],
"deny": [
"Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)",
"Read(~/.ssh/**)", "Read(~/.gnupg/**)", "Read(~/.git-credentials)",
"Bash(curl *)", "Bash(wget *)", "Bash(rm -rf *)", "Bash(sudo *)",
"Bash(git push --force*)", "Bash(git reset --hard*)"
]
},
"model": "opus",
"hooks": {
"SessionStart": [{ "matcher": "startup|resume", "hooks": [{ "type": "command", "command": "~/.claude/hooks/session-context.sh", "timeout": 5 }] }],
"PreToolUse": [{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "~/.claude/hooks/pre-commit-changelog.sh", "timeout": 10 }, { "type": "command", "command": "CMD=$(jq -r '.tool_input.command'); if echo \"$CMD\" | grep -qE 'git[[:space:]]+push.*(main|master)'; then echo 'BLOCKED' >&2; exit 2; fi" }] }],
"PostToolUse": [{ "matcher": "Edit|Write", "hooks": [{ "type": "command", "command": "~/.claude/hooks/auto-fmt-sol.sh", "timeout": 30 }] }],
"Notification": [{ "matcher": "permission_prompt|idle_prompt", "hooks": [{ "type": "command", "command": "~/.claude/hooks/notify-attention.sh", "timeout": 5 }] }]
},
"sandbox": { "enabled": true, "autoAllowBashIfSandboxed": true },
"enabledPlugins": {
"code-simplifier@claude-plugins-official": true,
"security-guidance@claude-plugins-official": true,
"building-secure-contracts@trailofbits": true,
"solidity-function-audit-team@solidity-audit-skills": true
},
"alwaysThinkingEnabled": true,
"autoUpdatesChannel": "latest"
}
</details>
<details><summary>.claude/settings.json (project)</summary>
{
"permissions": {
"deny": [
"Read(./node_modules/**)",
"Read(./packages/mcp/node_modules/**)"
]
}
}
</details>
<details><summary>.claude/settings.local.json (project local)</summary>
{
"permissions": {
"allow": [
"mcp__context7__resolve-library-id",
"mcp__context7__query-docs",
"Bash(tail:*)",
"Bash(xargs rm -v)",
"Bash(head:*)",
"WebFetch(domain:registry.npmjs.org)"
]
}
}This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗