#11878: fix: add missing error handler to execDocker child process
agents
stale
## Summary
- `execDocker()` in `src/agents/sandbox/docker.ts` only attaches a `close` event handler to the spawned child process
- If `docker` is not installed or cannot be executed, `spawn` emits an `error` event (ENOENT) that goes unhandled — the returned Promise hangs indefinitely and Node.js may crash with an unhandled exception
- Adds `child.on("error", reject)` to match the pattern used by other spawn callsites in the project (`bash-tools.exec.ts:767`, `runner.ts:474`, `entry.ts:67`, etc.)
## Test plan
- [x] Existing sandbox tests pass
- [x] One-line change, follows established project pattern
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates `execDocker()` (`src/agents/sandbox/docker.ts`) to attach an `error` event handler to the spawned `docker` child process (`child.on("error", reject)`). This ensures the returned Promise rejects (instead of hanging / crashing on an unhandled error event) when `spawn("docker", ...)` fails immediately (e.g., `ENOENT` when Docker is not installed or executable). The change aligns `execDocker()` with other spawn callsites in the repo that already handle `error` events.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change is a single, targeted addition that fixes a definite failure mode (unhandled child process `error` events) without altering normal-success behavior. It matches established patterns for `spawn()` usage and narrows the chance of hung Promises or process crashes when Docker is missing/unexecutable.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#13873: fix(sandbox): prevent Windows PATH from poisoning docker exec
by alessandrorodi · 2026-02-11
80.5%
#14308: fix(sandbox): pass docker.env config to container creation
by wboudy · 2026-02-11
78.7%
#3240: Fix Docker build failures on Windows/WSL environments
by Attili-sys · 2026-01-28
77.7%
#8161: fix(sandbox): block dangerous environment variables from Docker con...
by yubrew · 2026-02-03
76.9%
#9657: fix(doctor): warn when sandbox mode enabled without Docker
by mcaxtr · 2026-02-05
76.5%
#8186: fix(sandbox): validate setupCommand to prevent shell injection
by yubrew · 2026-02-03
75.9%
#4897: fix: config logic issues (#4689, #4654)
by lailoo · 2026-01-30
75.6%
#11961: fix: exec tool wraps shebang scripts in heredoc to use correct inte...
by scott-memco · 2026-02-08
75.4%
#23400: Onboarding: set sandbox defaults when Docker is available
by bmendonca3 · 2026-02-22
75.2%
#23112: fix(sandbox): propagate docker.user to all exec commands
by dashed · 2026-02-22
75.1%