From 5f3c4692cea6e5fbbd1664ad7c0f95cdcbc8e75a Mon Sep 17 00:00:00 2001 From: cirospaciari Date: Thu, 25 May 2023 19:41:41 -0300 Subject: [PATCH 1/2] fix flush --- src/bun.js/webcore/streams.zig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index 186b9304a0f725..e20e5a3bbd6d97 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -2377,8 +2377,7 @@ pub fn HTTPServerWritable(comptime ssl: bool) type { this.has_backpressure = false; return true; } else { - const backpressure = this.res.write(buf); - this.has_backpressure = backpressure; + this.has_backpressure = !this.res.write(buf); return true; } @@ -2486,20 +2485,28 @@ pub fn HTTPServerWritable(comptime ssl: bool) type { fn flushFromJSNoWait(this: *@This()) JSC.Node.Maybe(JSValue) { if (this.hasBackpressure() or this.done) { + log("flushFromJSNoWait: backpressure or done", .{}); + return .{ .result = JSValue.jsNumberFromInt32(0) }; } const slice = this.readableSlice(); if (slice.len == 0) { + log("flushFromJSNoWait: no readableSlice", .{}); + return .{ .result = JSValue.jsNumberFromInt32(0) }; } const success = this.send(slice); if (success) { + log("flushFromJSNoWait: success", .{}); + this.handleWrote(@truncate(Blob.SizeType, slice.len)); return .{ .result = JSValue.jsNumber(slice.len) }; } + log("flushFromJSNoWait: fail to send", .{}); + return .{ .result = JSValue.jsNumberFromInt32(0) }; } From c602e5717ee4c4247d726c35f06c121b0b5ac6da Mon Sep 17 00:00:00 2001 From: cirospaciari Date: Thu, 25 May 2023 19:43:17 -0300 Subject: [PATCH 2/2] remove logs --- src/bun.js/webcore/streams.zig | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index e20e5a3bbd6d97..dddfcbaf53991f 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -2485,28 +2485,20 @@ pub fn HTTPServerWritable(comptime ssl: bool) type { fn flushFromJSNoWait(this: *@This()) JSC.Node.Maybe(JSValue) { if (this.hasBackpressure() or this.done) { - log("flushFromJSNoWait: backpressure or done", .{}); - return .{ .result = JSValue.jsNumberFromInt32(0) }; } const slice = this.readableSlice(); if (slice.len == 0) { - log("flushFromJSNoWait: no readableSlice", .{}); - return .{ .result = JSValue.jsNumberFromInt32(0) }; } const success = this.send(slice); if (success) { - log("flushFromJSNoWait: success", .{}); - this.handleWrote(@truncate(Blob.SizeType, slice.len)); return .{ .result = JSValue.jsNumber(slice.len) }; } - log("flushFromJSNoWait: fail to send", .{}); - return .{ .result = JSValue.jsNumberFromInt32(0) }; }