Skip to content

Daemon FileHandle leak: ERR_INVALID_STATE on concurrent launches #185

Description

@doink-kindo

Summary

The agentctl daemon throws "ERR_INVALID_STATE: A FileHandle object was closed during garbage collection" when multiple concurrent agentctl launch commands are issued. This causes new launches to fail with "Connection closed before response received".

Error

[Error: A FileHandle object was closed during garbage collection. This used to be allowed with a deprecation warning but is now considered an error. Please close FileHandle objects explicitly. File descriptor: 12 (/Users/ms/.agentctl/daemon.stdout.log)] {
  code: 'ERR_INVALID_STATE'
}
Node.js v25.5.0

Impact

  • Prevented launching 2 conflict-resolution agents for PRs with merge conflicts during patrol
  • 4 earlier review-fix agents launched successfully before the daemon entered this state
  • Error appears to be triggered by concurrent or rapid-sequential launch requests

Reproduction

  1. Launch multiple agents in rapid succession (e.g., 4+ agentctl launch opencode calls)
  2. Subsequent launches fail with "Connection closed before response received"
  3. Daemon stdout shows the FileHandle leak error

Environment

  • agentctl version: 1.9.1
  • Node.js: v25.5.0
  • Host: macOS (arm64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions