Preflight Checklist
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_execution result 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/skills directory) in the same errors array 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_execution result 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
Environment
- Claude Code: 2.1.25
- OS: Linux (VPS with ~6GB free)
- Node.js: 20.20.0
Preflight Checklist
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 theerrorsarray 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:
error_during_executionresult has zeroed-out usage counters ("total_cost_usd": 0,"num_turns": 0), losing the actual usage data from the session/etc/claude-code/.claude/skillsdirectory) in the sameerrorsarray with no severity or categorizationReproducible 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?
error_during_executionresult should preserve the actual usage data (tokens, cost) from the session, even if the session ended with an error"error_code": "ENOSPC"field)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
Environment