Skip to content

🤖 fix: destroy stdio streams on timeout to prevent Windows hanging#2785

Merged
ibetitsmike merged 3 commits intomainfrom
mike/fix-timeout-stream-hang
Mar 5, 2026
Merged

🤖 fix: destroy stdio streams on timeout to prevent Windows hanging#2785
ibetitsmike merged 3 commits intomainfrom
mike/fix-timeout-stream-hang

Conversation

@ibetitsmike
Copy link
Contributor

Summary

Fix bash tool timeout hanging on Windows by destroying stdio streams in the DisposableProcess cleanup callback, ensuring Web ReadableStream readers see EOF after process kill.

Background

On Windows, when timeout fires and taskkill /PID /T /F kills the process tree, Node.js stdio pipe handles don't always close. This causes reader.read() in consumeStream() to hang indefinitely, since Promise.all([exitCode, consumeStdout, consumeStderr]) in bash.ts waits for all three. Manual abort works because it explicitly cancels stream readers — timeout had no such mechanism.

Implementation

  • LocalBaseRuntime.ts / DevcontainerRuntime.ts: In the disposable.addCleanup() callback (runs only on timeout/abort, not normal exit), after killing the process tree, queue EOF on stdout/stderr via push(null) then destroy all stdio streams in setImmediate. The two-phase approach (EOF then destroy) avoids ABORT_ERR rejections from Readable.toWeb() while still forcing handle teardown.
  • Deleted bashExecutionService.ts: Confirmed dead code (nothing imports it). Had a separate DisposableProcess with Unix-only process.kill(-pid, "SIGKILL") — removed entirely rather than patching.

Risks

Low. The cleanup callback only fires on explicit dispose() (timeout/abort path), never on normal process exit. Buffered output from successful commands is unaffected.


Generated with mux • Model: anthropic:claude-opus-4-6 • Thinking: xhigh • Cost: $4.20

@ibetitsmike
Copy link
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike ibetitsmike added this pull request to the merge queue Mar 5, 2026
Merged via the queue into main with commit 2cf0025 Mar 5, 2026
23 checks passed
@ibetitsmike ibetitsmike deleted the mike/fix-timeout-stream-hang branch March 5, 2026 01:20
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