From fcef720d485fa89e44f4f2ec147d7a55e42aa301 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Fri, 30 May 2025 03:40:28 -0700 Subject: [PATCH] uno --- src/bun.js/api/bun/h2_frame_parser.zig | 4 ++-- test/js/node/test/parallel/test-http2-pipe-named-pipe.js | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bun.js/api/bun/h2_frame_parser.zig b/src/bun.js/api/bun/h2_frame_parser.zig index 5721ba69f6..dc1ecb5281 100644 --- a/src/bun.js/api/bun/h2_frame_parser.zig +++ b/src/bun.js/api/bun/h2_frame_parser.zig @@ -1787,7 +1787,6 @@ pub const H2FrameParser = struct { } fn checkIfShouldAutoFlush(this: *H2FrameParser) void { - log("writeBuffer.len {} {}", .{ this.writeBuffer.slice()[this.writeBufferOffset..].len, this.isServer }); const corkedBuffer = if (CORKED_H2) |corked| if (@intFromPtr(corked) == @intFromPtr(this)) CORK_OFFSET else 0 else 0; if (corkedBuffer > 0) { this.registerAutoFlush(); @@ -1994,6 +1993,7 @@ pub const H2FrameParser = struct { this.sendGoAway(frame.streamIdentifier, ErrorCode.FRAME_SIZE_ERROR, "Invalid dataframe frame size", this.lastStreamID, true); return data.len; } + const end: usize = @min(@as(usize, @intCast(this.remainingLength)), data.len); var payload = data[0..end]; @@ -2026,7 +2026,7 @@ pub const H2FrameParser = struct { payload = payload[0..@min(@as(usize, @intCast(data_needed)), payload.len)]; const chunk = this.handlers.binary_type.toJS(payload, this.handlers.globalObject); // its fine to truncate because is not possible to receive more data than u32 here, usize is only because of slices in size - this.ajustWindowSize(stream, frame.length); + this.ajustWindowSize(stream, @truncate(payload.len)); this.dispatchWithExtra(.onStreamData, stream.getIdentifier(), chunk); emitted = true; } else { diff --git a/test/js/node/test/parallel/test-http2-pipe-named-pipe.js b/test/js/node/test/parallel/test-http2-pipe-named-pipe.js index 027893b9f8..d2303dd59f 100644 --- a/test/js/node/test/parallel/test-http2-pipe-named-pipe.js +++ b/test/js/node/test/parallel/test-http2-pipe-named-pipe.js @@ -16,21 +16,27 @@ tmpdir.refresh(); const loc = fixtures.path('person-large.jpg'); const fn = tmpdir.resolve('person-large.jpg'); -const server = http2.createServer(); +const server = http2.createServer({ + // initialWindowSize: 655360, +}); server.on('stream', common.mustCall((stream) => { + console.log("stream"); const dest = stream.pipe(fs.createWriteStream(fn)); stream.on('end', common.mustCall(() => { + console.log("end"); stream.respond(); stream.end(); })); dest.on('finish', common.mustCall(() => { + console.log("finish"); assert.strictEqual(fs.readFileSync(fn).length, fs.readFileSync(loc).length); })); })); + server.listen(common.PIPE, common.mustCall(() => { const client = http2.connect('http://localhost', { createConnection(url) {