From 6cdb7e77dda5d1affe8a1b033e6d35ab1e78234d Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 15 Nov 2022 21:01:08 -0800 Subject: [PATCH] Handle blocking initial read --- src/bun.js/webcore/streams.zig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index 253deda55a..7bb1c8f177 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -3791,6 +3791,24 @@ pub const FileReader = struct { this.buf = read_buf; } + this.watch(fd); + return .{ + .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,