diff options
| author | 2022-12-01 23:28:42 -0800 | |
|---|---|---|
| committer | 2022-12-01 23:28:42 -0800 | |
| commit | f84f77d1ed171183accbc99b2dac22d45312f388 (patch) | |
| tree | 0277ad86070c0fb6c0d5a79c061d76ffc444da66 | |
| parent | 425f4b0de1b7c853606f4bcb936fa6597202a8ba (diff) | |
| download | bun-f84f77d1ed171183accbc99b2dac22d45312f388.tar.gz bun-f84f77d1ed171183accbc99b2dac22d45312f388.tar.zst bun-f84f77d1ed171183accbc99b2dac22d45312f388.zip | |
[streams] Handle empty state
Diffstat (limited to '')
| -rw-r--r-- | src/bun.js/webcore/streams.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index 0cd35a3ee..a7f90a0e6 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -4439,6 +4439,18 @@ pub const FileReader = struct { pub fn onPullInto(this: *FileReader, buffer: []u8, view: JSC.JSValue) StreamResult { std.debug.assert(this.started); + + // this state isn't really supposed to happen + // but we handle it just in-case + if (this.lazy_readable == .empty) { + if (this.buffered_data.len == 0) { + return .{ .done = {} }; + } + + return .{ .owned_and_done = this.drainInternalBuffer() }; + } + + return this.readable().read(buffer, view, this.globalThis()); } |
