Skip to content

fix: add exit event fallback for child process close hang on Windows#24783

Open
bingkxu wants to merge 1 commit intoanomalyco:devfrom
bingkxu:fix/windows-childprocess-close-hang-v2
Open

fix: add exit event fallback for child process close hang on Windows#24783
bingkxu wants to merge 1 commit intoanomalyco:devfrom
bingkxu:fix/windows-childprocess-close-hang-v2

Conversation

@bingkxu
Copy link
Copy Markdown

@bingkxu bingkxu commented Apr 28, 2026

Issue for this PR

Closes #24784

Type of change

  • Bug fix

What does this PR do?

On Windows, when a child process spawns grandchild processes (e.g., build tools like hvigor/Gradle daemons), the grandchild may inherit the stdout/stderr pipe handles. Even after the direct child exits, these inherited handles keep the pipe open, preventing Node.js close event from firing.

The exitCode in cross-spawn-spawner.ts was resolved only on close event, causing bash tool to hang indefinitely in Effect.raceAll waiting for handle.exitCode.

This PR adds a fallback: resolve exitCode on exit event with a 2-second delay. If close fires within 2 seconds (normal case), behavior is unchanged. If close does not fire (daemon holds pipe), fallback resolves after 2 seconds.

How did you verify your code works?

  1. Typecheck passes: bun typecheck in packages/core
  2. New test passes: exit fallback resolves when close hangs due to grandchild holding pipe
  3. Existing tests: 24 pass

Screenshots / recordings

N/A - This is a backend fix, no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

On Windows, when a child process spawns grandchild processes (e.g., build
tools like hvigor/Gradle daemons), the grandchild may inherit the stdout/stderr
pipe handles. Even after the direct child exits, these inherited handles keep
the pipe open, preventing Node.js 'close' event from firing.

Since exitCode was resolved only on 'close', this caused bash tool to hang
indefinitely in Effect.raceAll waiting for handle.exitCode.

Fix: resolve exitCode on 'exit' event with a 2-second fallback. If 'close'
fires within 2 seconds (normal case), behavior is unchanged. If 'close' does
not fire (daemon holds pipe handle), fallback resolves after 2 seconds.

Added test for Windows-specific grandchild holding pipe scenario.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant