diff options
author | 2022-11-15 21:01:08 -0800 | |
---|---|---|
committer | 2022-11-15 21:01:08 -0800 | |
commit | 6cdb7e77dda5d1affe8a1b033e6d35ab1e78234d (patch) | |
tree | 735b56629e1a9f1ee7a3f6773481ddc7c4b57c07 /src | |
parent | 0e7ed4c6672a21ad30135de01f3a60f43d135e7b (diff) | |
download | bun-6cdb7e77dda5d1affe8a1b033e6d35ab1e78234d.tar.gz bun-6cdb7e77dda5d1affe8a1b033e6d35ab1e78234d.tar.zst bun-6cdb7e77dda5d1affe8a1b033e6d35ab1e78234d.zip |
Handle blocking initial read
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/webcore/streams.zig | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index 253deda55..7bb1c8f17 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -3796,6 +3796,24 @@ pub const FileReader = struct { .pending = &this.pending, }; } + } else if (this.isFIFO() and this.poll_ref == null and available_to_read == null) { + // we don't know if it's readable or not + if (!bun.isReadable(fd)) { + if (free_buffer_on_error) { + bun.default_allocator.free(buf_to_use); + buf_to_use = read_buf; + } + + if (view != .zero) { + this.view.set(this.globalThis(), view); + this.buf = read_buf; + } + + this.watch(fd); + return .{ + .pending = &this.pending, + }; + } } switch (Syscall.read(fd, buf_to_use)) { |