[CRITICAL] Extension Host OOM Crash During Initialization - No Workaround Exists
Issue Summary
Claude Code extension causes VS Code Extension Host to crash with "JavaScript heap out of memory" error during initialization. CRITICAL: Crash occurs even when ALL node_modules folders are completely removed from the project, proving this is NOT a node_modules issue but a fundamental bug in Claude Code's initialization process.
Environment
- VS Code Version: 1.105.1 (user setup)
- Commit: 7d842fb85a0275a4a8e4d7e040d2625abbf7f084
- Electron: 37.6.0
- Node.js: 22.19.0
- V8: 13.8.258.32-electron.0
- Claude Code Extension Version: [Need to check]
- OS: Windows 11 (Build 26200)
- Project Type: Full-stack application (Python/FastAPI backend + Node.js frontend)
Error Details
Initial Error Message:
\\\`
[Extension Host] (node:13528) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
Extension Host
<--- Last few GCs --->
[31188:000033AC001A4000] 13179 ms: Mark-Compact (reduce) 3512.6 (3528.3) -> 3418.7 (3431.4) MB, pooled: 0.0 MB, 60.15 / 0.01 ms (average mu = 0.485, current mu = 0.666) last resort; GC in old space requested
[31188:000033AC001A4000] 13258 ms: Mark-Compact (reduce) 3418.7 (3431.4) -> 3418.7 (3430.4) MB, pooled: 0.0 MB, 79.13 / 0.00 ms (average mu = 0.326, current mu = 0.000) last resort; GC in old space requested
[31188:1028/144141.933:ERROR:electron\shell\common\node_bindings.cc:178] OOM error in V8:
CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Extension host (LocalProcess pid: 31188) terminated unexpectedly. Code: 0, Signal: unknown
ERR Extension host (LocalProcess pid: 31188) terminated unexpectedly. The following extensions were running: Anthropic.claude-code
Extension host terminated unexpectedly 3 times within the last 5 minutes.
\\\`
Project Structure:
\\\\
C:\Projects\STT\A Skytek SMS Platform\
├── node_modules/ (3.5GB, 250k+ files)
├── backend/
│ └── node_modules/ (Large)
├── test-webhook-sms/
│ └── node_modules/ (Large)
├── frontend-v1-archive/
├── venv/ (Python virtual environment)
├── logs/
├── puppeteer-chrome-profile/
└── ... (other files)
\\
Reproduction Steps
- Open VS Code to a project with multiple large \
node_modules\folders - Have Claude Code extension installed and enabled
- Open the project folder
- Watch the Extension Host output panel (View → Output → Extension Host)
- Extension Host crashes during initialization with OOM error
- Claude Code never loads successfully
What I've Tried
❌ Attempted Fixes (Did NOT work):
- Increased NODE_OPTIONS in VS Code User Settings:
\\\json\
{
"NODE_OPTIONS": "--max-old-space-size=8192"
}
\\
→ Extension Host still crashed
- Added VS Code files.exclude:
\\\json\
{
"files.exclude": {
"**/node_modules": true,
"**/__pycache__": true,
...
}
}
\\
→ Extension Host still crashed (Claude Code doesn't respect VS Code exclusions)
- Set extension affinity:
\\\json\
{
"extensions.experimental.affinity": {
"anthropic.claude-code": 1
}
}
\\
→ Extension Host still crashed
❌ CRITICAL TEST RESULT: Hidden node_modules Did NOT Fix the Issue
After completely removing ALL node_modules folders:
- Verified with \
glob\that zero node_modules folders exist in the project - Created \
.claude/settings.json\with \permissions.deny\for all large directories - Configured VS Code \
files.exclude\and \search.exclude\for node_modules - Set \
NODE_OPTIONS: "--max-old-space-size=8192"\in VS Code user settings
Result: Extension Host STILL crashed with OOM at ~3.6GB
Latest Error (with hidden node_modules):
\\\\
[31272:00004E14001A4000] 12719 ms: Scavenge 3603.5 (3619.3) -> 3603.1 (3621.6) MB
[31272:00004E14001A4000] 12722 ms: Scavenge 3603.1 (3621.6) -> 3603.0 (3621.6) MB
[31272:1028/145408.324:ERROR:electron\shell\common\node_bindings.cc:178] OOM error in V8:
MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
\\
Key Findings:
- Memory consumption increased from ~3.4GB (first crash) to ~3.6GB (with NODE_OPTIONS)
- Error changed from "CALL_AND_RETRY_LAST" to "MarkCompactCollector: young object promotion failed"
- This proves the crash is NOT caused by node_modules indexing
- Claude Code consumes 3.6GB during initialization regardless of project contents
🔵 Proper Solution Created (But Cannot Test):
Created \.claude/settings.json\ with \permissions.deny\:
\\\json\
{
"permissions": {
"defaultMode": "bypassPermissions",
"deny": [
"Read(./node_modules/**)",
"Read(./backend/node_modules/**)",
"Read(./test-webhook-sms/node_modules/**)",
...
]
}
}
\\
Status: Cannot test effectiveness because Extension Host crashes before Claude Code loads
Expected Behavior
- Extension Host should NOT crash during initialization
- Claude Code should respect \
.claude/settings.json\exclusions - Extension Host should allocate sufficient memory or handle large projects gracefully
Actual Behavior
- Extension Host crashes with OOM before Claude Code fully loads
- The \
NODE_OPTIONS\setting in VS Code user settings has minimal effect (increased crash threshold slightly from 3.4GB to 3.6GB) - Crash occurs regardless of project contents - even with ALL node_modules removed
- Claude Code initialization process consumes 3.6GB of memory, exceeding Extension Host limits
- \
.claude/settings.json\exclusions cannot help because crash occurs during initialization before settings are loaded
Related Issues
- #336 - OOM when running Claude in specific codebase
- #2099 - Claude Code Fatal Memory Error
- #1421 - Recurring crashes: JavaScript Heap Out of Memory
- #4953 - Memory Leak - Process Grows to 120+ GB RAM
- #166 - Ignore 'node_modules' by default
- #187 - Exclude node_modules from project context
Suggested Fixes
- URGENT: Investigate why Claude Code initialization consumes 3.6GB of memory regardless of project contents
- Short-term: Implement lazy loading or streaming during initialization to reduce memory footprint
- Medium-term: Respect Extension Host memory limits and fail gracefully with user-friendly error message
- Long-term: Optimize memory usage throughout Claude Code lifecycle, use incremental indexing
Impact
- Severity: CRITICAL - Extension is completely unusable on this project
- Frequency: 100% reproducible every time VS Code opens this project
- User Impact: Cannot use Claude Code extension at all
- Workaround: NONE - Even removing all node_modules folders does not fix the crash
- Root Cause: Claude Code initialization process fundamentally incompatible with Extension Host memory limits
- Business Impact: Production development workflow blocked for users with similar project structures
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗