-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
spawn EBADF when gateway file descriptor count is high #77750
Copy link
Copy link
Closed as not planned
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.Issue affects a taxonomy feature currently scored M4/M5.staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.Issue affects a taxonomy feature currently scored M4/M5.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Priority
None yet
Problem
The gateway process accumulates thousands of open file descriptors (observed 14,039, of which 13,982 are
.mdfiles likely from plugins like claude-mem/lossless-claw). Whenchild_process.spawnis called via exec tool, it fails withError: spawn EBADFbecauseposix_spawncannot handle the massive fd table.Error logs
This affects ALL exec tool calls — MCP server startup, shell scripts, Python scripts, simple
lscommands.Root cause
The default
stdinModeincreateChildAdapteris"inherit"when no input is provided. When combined with the fd leak, theinherit+detached: truespawn fails with EBADF. The existingno-detachfallback doesn't help because it still uses"inherit"stdin and the same fd table is inherited.Additionally, the fd leak itself indicates that some plugin is opening markdown files without closing them.
Fix approach
src/process/supervisor/adapters/child.ts: DefaultstdinModeto"pipe"whenprocess.stdin.isTTYis false (i.e., service-managed gateway). In service mode, stdin is/dev/nullso"inherit"provides no benefit but exposes the child to fd table issues.src/process/supervisor/adapters/child.ts: Always add apipe-stdinfallback that retries with["pipe", "pipe", "pipe"]+detached: false, so even if the first spawn fails with EBADF, it retries with a safe configuration.Environment
Related
Will open a PR with the fix.