Skip to content

fix(shell): bound Windows post-exit pipe draining - #46085

Draft
Hona wants to merge 2 commits into
anomalyco:v2from
Hona:windows-shell-drain
Draft

fix(shell): bound Windows post-exit pipe draining#46085
Hona wants to merge 2 commits into
anomalyco:v2from
Hona:windows-shell-drain

Conversation

@Hona

@Hona Hona commented Aug 29, 2026

Copy link
Copy Markdown
Member

Issue for this PR

Windows shell commands such as bunx agent-browser can leave descendants holding stdout/stderr open after the parent exits, preventing shell completion.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a 200 ms, Windows-only drain window after parent exit. If inherited writers still prevent EOF, signal EOF on captured stdout/stderr so the existing output pump can finish and flush its file. Normal closure cancels the timer; POSIX is unchanged.

Nine added lines in the existing spawner. No new package, native code, dependencies, or test files.

This is a bounded cutoff, not a lossless-output guarantee: unread trailing output and later descendant writes can be excluded, and later writes can encounter a broken pipe. Saving captured output to a file does not recover bytes still in the pipes.

How did you verify your code works?

  • bun typecheck in packages/util: passed.
  • Prettier and git diff --check: passed.
  • Ran external experiments on this Windows host with Bun 1.4.0 and Node 24.14.1. Across 144 idle-descendant cases, all foreground bytes reached the capture before the parent-exit event, including 16 MiB per channel through PowerShell -> bunx -> a harmless local fixture.
  • Six deliberately delayed-output controls confirmed that descendants can write later; this is not a lossless guarantee for arbitrary programs.
  • Exercised the actual spawner at 1 second and 200 ms. It retained the complete 2 MiB foreground body and both tails at 200 ms, completing about 207-210 ms after observed parent exit instead of 1006-1009 ms. Writes at 50/150 ms were captured; writes at 250/500 ms received EPIPE.
  • Cached agent-browser@0.35.1 source prints command responses before CLI exit and uses null/private pipes for daemon/browser output. The actual browser was not executed because of the host workaround, so browser-specific runtime verification remains outstanding.
  • No repository test files added; experiment scripts and results stay outside the repository.

Screenshots / recordings

Not a UI change.

Checklist

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

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.

1 participant