diff options
author | 2022-11-23 07:14:33 -0800 | |
---|---|---|
committer | 2022-11-23 07:14:33 -0800 | |
commit | ac36ea51cfb85130403ac09299f8e1207bad4bcb (patch) | |
tree | a05bc2d34295bc0087b68b799155f18050451721 /src/bun.js/api/server.zig | |
parent | ae3fcb5bd89a4ac908ba6d4cdb1be4e7c7f0ea81 (diff) | |
download | bun-ac36ea51cfb85130403ac09299f8e1207bad4bcb.tar.gz bun-ac36ea51cfb85130403ac09299f8e1207bad4bcb.tar.zst bun-ac36ea51cfb85130403ac09299f8e1207bad4bcb.zip |
possibly more reliable Bun.spawn (#1547)
* wip
* wip
* Fix bug with stdin
* zig fmt
* seems to work!
* Update streams.test.js
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/api/server.zig')
-rw-r--r-- | src/bun.js/api/server.zig | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index c4724b1b8..531d4830b 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -1428,10 +1428,17 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp stream.value.ensureStillAlive(); - if (!stream.isLocked(this.server.globalThis)) { - streamLog("is not locked", .{}); - this.renderMissing(); - return; + const is_in_progress = response_stream.sink.has_backpressure or !(response_stream.sink.wrote == 0 and + response_stream.sink.buffer.len == 0); + + if (!stream.isLocked(this.server.globalThis) and !is_in_progress) { + if (JSC.WebCore.ReadableStream.fromJS(stream.value, this.server.globalThis)) |comparator| { + if (std.meta.activeTag(comparator.ptr) == std.meta.activeTag(stream.ptr)) { + streamLog("is not locked", .{}); + this.renderMissing(); + return; + } + } } this.resp.onAborted(*ResponseStream, ResponseStream.onAborted, &response_stream.sink); |