OOM crash: background SSH/gcloud commands accumulate and exhaust Node.js heap

Resolved 💬 3 comments Opened Feb 6, 2026 by DP-Brian Closed Feb 9, 2026

Description

Claude Code crashes with FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory when running gcloud compute ssh commands that hang indefinitely.

Steps to Reproduce

  1. Use Claude Code to SSH into a remote server via gcloud compute ssh
  2. The SSH command hangs (gcloud adds -t flag requiring pseudo-terminal, which doesn't work in Claude Code's non-interactive shell)
  3. The command gets pushed to background automatically
  4. Multiple SSH attempts accumulate as hanging background processes
  5. Eventually Node.js heap fills up and Claude Code crashes with OOM

Crash Output

<--- Last few GCs --->
[3927662:0x561ad128e000]  1161058 ms: Mark-Compact 4042.6 (4139.0) -> 4031.2 (4140.5) MB, poo
[3927662:0x561ad128e000]  1163334 ms: Mark-Compact 4044.4 (4140.7) -> 4036.1 (4144.7) MB, poo

<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Root Cause

gcloud compute ssh adds -t (force pseudo-terminal) by default. In Claude Code's non-interactive Bash tool, this causes the SSH process to hang indefinitely. When the tool times out, the process moves to background but continues consuming memory. Multiple retries compound the issue.

Suggested Fixes

  1. Kill background processes that timeout — When a Bash command times out and gets backgrounded, the process should be killed rather than left running
  2. Detect hanging background tasks — Warn or auto-cleanup when multiple background tasks are accumulating
  3. Memory pressure monitoring — Detect when heap usage is critically high and proactively clean up

Environment

  • Claude Code: 2.1.33
  • OS: Fedora Linux (6.18.7-200.fc43.x86_64)
  • Node.js heap limit: ~4GB
  • Triggered by: gcloud compute ssh with --command flag

Workaround

Currently no reliable workaround. Direct ssh without -t flag should work but gcloud wraps it automatically. Using --dry-run to get the raw SSH command and then modifying it manually is possible but cumbersome.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗