[BUG] ENOSPC error_during_execution should provide actionable guidance and not cascade silently
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?
When the disk runs out of space during a Claude Code execution, the CLI returns a result with "subtype": "error_during_execution" and "is_error": true, but the errors array contains the ENOSPC error message mixed with unrelated ENOENT errors, making it hard for calling tools to detect and handle the disk space issue specifically.
Key issues:
- The
error_during_executionresult has zeroed-out usage counters ("total_cost_usd": 0,"num_turns": 0), losing the actual usage data from the session - ENOSPC errors are mixed with unrelated errors (e.g., missing
/etc/claude-code/.claude/skillsdirectory) in the sameerrorsarray with no severity or categorization - There's no structured way to detect that the failure was specifically caused by disk space exhaustion
Reproducible Example
Running Claude Code on a system with ~6GB free space for an 8-minute solve session resulted in disk exhaustion (potentially exacerbated by the debug logging loop described in #16093).
Result returned:
{
"type": "result",
"subtype": "error_during_execution",
"is_error": true,
"num_turns": 0,
"total_cost_usd": 0,
"errors": [
"ENOSPC: no space left on device, write",
"Error: ENOENT: no such file or directory, scandir '/etc/claude-code/.claude/skills'",
"Error: ENOENT: no such file or directory, scandir '/home/hive/.claude/skills'",
"Error: NON-FATAL: Lock acquisition failed for /home/hive/.local/share/claude/versions/2.1.25"
]
}
Work was actually completed - the Claude session committed code, pushed to GitHub, and updated the PR description before the ENOSPC error terminated the session. The zeroed usage counters make this indistinguishable from a session that did nothing.
What Should Happen?
- The
error_during_executionresult should preserve the actual usage data (tokens, cost) from the session, even if the session ended with an error - Errors should be categorized or structured so ENOSPC can be detected programmatically (e.g.,
"error_code": "ENOSPC"field) - ENOSPC errors should be distinct from benign ENOENT errors for missing optional directories
- Ideally, Claude Code should detect disk space issues early and provide actionable guidance before the situation cascades
Workarounds
We've added ENOSPC detection in our calling tool (hive-mind) by pattern-matching on the errors array strings, and added a disk space check before log upload operations.
Related Issues
- #16093 - Infinite debug logging loop that can fill disk with 200GB+ of debug files
- #9496 - ENOSPC during workflow despite available disk space
- #7624 - Startup crash in Docker from ENOSPC on settings file watcher
Environment
- Claude Code: 2.1.25
- OS: Linux (VPS with ~6GB free)
- Node.js: 20.20.0
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗