Skip to content

[BUG] ENOSPC error_during_execution should provide actionable guidance and not cascade silently #22584

@konard

Description

@konard

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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:

  1. 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
  2. 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
  3. 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?

  1. The error_during_execution result should preserve the actual usage data (tokens, cost) from the session, even if the session ended with an error
  2. Errors should be categorized or structured so ENOSPC can be detected programmatically (e.g., "error_code": "ENOSPC" field)
  3. ENOSPC errors should be distinct from benign ENOENT errors for missing optional directories
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions