fix(node/stream): handle 'close' event in fromReadable to prevent Windows hang - #182
Merged
Conversation
📝 WalkthroughWalkthroughBumps package version (0.2.2 → 0.2.3) and augments Node readable stream handling by tracking end/close events: adds an ended flag, subscribes to "end" and "close" with guarded signal closure, and ensures both handlers are detached during cleanup. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
…dows hang On Windows, when a child process terminates, its stdio streams may emit 'close' without first emitting 'end'. Since fromReadable only listened for 'end' to close the signal, the Effection subscription would never complete. This caused the Win32 exec implementation to hang forever waiting for stdoutDone/stderrDone resolvers that gate on stream drain. The close handler is guarded: it only closes the signal when 'end' has not already fired. This prevents a race where 'close' arrives before all buffered 'data' events have been consumed, which would drop chunks and hang tests waiting for expected output. Also bumps @effectionx/node version to 0.2.3.
taras
force-pushed
the
fix/windows-stream-hang
branch
from
March 7, 2026 12:20
c1f48b2 to
c9fec19
Compare
cowboyd
approved these changes
Mar 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
On Windows, when a child process terminates, its stdio streams may emit
closewithout first emittingend. SincefromReadable()only listened forendto close the Effection signal, the subscription would never complete. This caused the Win32exec()implementation to hang forever — it gates process completion onstdoutDone/stderrDoneresolvers that only resolve when the stream is fully drained.This manifested as the Windows CI hanging indefinitely on the "Run peer dependency matrix tests" step, which spawns
node --testsubprocesses viaexec().Approach
Add a
closeevent listener tofromReadable()that also closes the signal. Sincesignal.close()is idempotent, receiving bothendandclose(the normal case on Linux/macOS) is safe. On Windows, whichever event fires first will close the signal and unblock the stream consumer.