Skip to content

Commit 163028a

Browse files
author
Taras Mankovski
committed
fix(node/stream): handle 'close' event in fromReadable to prevent Windows 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. Adding a 'close' listener ensures the signal closes regardless of which event the platform emits first. The signal.close() call is idempotent, so receiving both 'end' and 'close' is safe.
1 parent c924aba commit 163028a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

node/stream.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ export function fromReadable(target: Readable): Stream<Uint8Array, void> {
3838

3939
target.on("data", listener);
4040
target.on("end", signal.close);
41+
target.on("close", signal.close);
4142
target.on("error", errorHandler);
4243

4344
try {
4445
yield* provide(yield* signal);
4546
} finally {
4647
target.off("data", listener);
4748
target.off("end", signal.close);
49+
target.off("close", signal.close);
4850
target.off("error", errorHandler);
4951
signal.close();
5052
}

0 commit comments

Comments
 (0)