Skip to content

Bug: bash tool hangs on Windows when grandchild process inherits stdout pipe #24784

@bingkxu

Description

@bingkxu

Description

On Windows, when running build tools like hvigor/Gradle daemons through the bash tool, the command hangs indefinitely even after the child process exits.

Root Cause

When a child process spawns grandchild processes on Windows, the grandchild may inherit the stdout/stderr pipe handles. Even after the direct child exits (with exit code 0), these inherited handles keep the pipe open, preventing Node.js close event from firing.

In packages/core/src/cross-spawn-spawner.ts, the exitCode is resolved only when the close event fires. This causes Effect.raceAll to hang indefinitely waiting for handle.exitCode.

Reproduction

  1. Run a build command that spawns daemon processes (e.g., hvigorw assembleHap on HarmonyOS projects)
  2. Observe that bash tool hangs after the build completes
  3. The child process has exited but grandchild daemon still holds the pipe

Proposed Fix

Add a fallback in the exit event handler: if close does not fire within 2 seconds after exit, resolve exitCode using the exit event data. This matches the documented behavior difference between exit and close events in Node.js.

Environment

Platform: Windows
Node.js: v20+
OpenCode version: v1.14.x

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)windows

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