Compare commits

...

1 Commits

Author SHA1 Message Date
Claude Bot
ed05433496 fix(windows): handle libuv 1.51.0 spurious 0-byte pipe reads (#23071)
### What does this PR do?

Fixes #23071 - package.json scripts hanging on Windows in Bun v1.2.23.

The issue was introduced by the libuv 1.51.0 update in commit e3783c244f.
In libuv 1.51.0, Windows pipes can return 0-byte reads even when not at
EOF. The libuv update changed the stream read callback to use the actual
bytes read (`nreads`) instead of the full buffer, which exposed this
behavior.

WindowsBufferedReader was calling `onRead(.drained)` for 0-byte reads,
which would process the empty chunk but then never continue reading,
causing the process to hang waiting for data that never arrives.

The fix is simple: when we get a 0-byte read (nread == 0), just ignore
it and return. libuv will call us again when there's actual data. This
matches the intent of the fix that was already applied to FileReader.zig
in the same libuv update commit.

### How did you verify your code works?

The reproduction case from #23071:
1. `bun init bun-demo`
2. Add script: `{"scripts": {"dev": "bun index.ts"}}`
3. `bun dev` - previously hung, now works

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-07 04:30:13 +00:00

View File

@@ -928,7 +928,9 @@ pub const WindowsBufferedReader = struct {
switch (nread_int) {
0 => {
// EAGAIN or EWOULDBLOCK or canceled (buf is not safe to access here)
return this.onRead(.{ .result = 0 }, "", .drained);
// Certain readers (such as pipes) may return 0-byte reads even when
// not at EOF (libuv 1.51.0+). Just ignore them and wait for the next callback.
return;
},
uv.UV_EOF => {
_ = this.stopReading();