From e44e25ed268f3c59fb7029aa6e0d5da0203b01d3 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Tue, 21 Jan 2025 14:23:23 -0800 Subject: [PATCH] fix(http2) remove queue (#16573) Co-authored-by: Jarred Sumner --- docs/api/sql.md | 4 ++-- src/js/node/http2.ts | 24 +++++------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/docs/api/sql.md b/docs/api/sql.md index 53eae94b0bdbbc..e50c4edd99e63c 100644 --- a/docs/api/sql.md +++ b/docs/api/sql.md @@ -20,7 +20,7 @@ const activeUsers = await sql` {% features title="Features" %} -{% icon size=20 name="Shield" /%} Tagged template literals to protect againt SQL injection +{% icon size=20 name="Shield" /%} Tagged template literals to protect against SQL injection {% icon size=20 name="GitMerge" /%} Transactions @@ -561,7 +561,7 @@ The plan is to add more database drivers in the future. npm packages like postgres.js, pg, and node-postgres can be used in Bun too. They're great options. -Two reaons why: +Two reasons why: 1. We think it's simpler for developers to have a database driver built into Bun. The time you spend library shopping is time you could be building your app. 2. We leverage some JavaScriptCore engine internals to make it faster to create objects that would be difficult to implement in a library diff --git a/src/js/node/http2.ts b/src/js/node/http2.ts index 5ce20ef2577818..512df1aedcc2b9 100644 --- a/src/js/node/http2.ts +++ b/src/js/node/http2.ts @@ -44,7 +44,6 @@ const [H2FrameParser, assertSettings, getPackedSettings, getUnpackedSettings] = const sensitiveHeaders = Symbol.for("nodejs.http2.sensitiveHeaders"); const bunHTTP2Native = Symbol.for("::bunhttp2native::"); -const bunHTTP2StreamReadQueue = Symbol.for("::bunhttp2ReadQueue::"); const bunHTTP2Socket = Symbol.for("::bunhttp2socket::"); const bunHTTP2StreamFinal = Symbol.for("::bunHTTP2StreamFinal::"); @@ -1507,13 +1506,8 @@ function assertSession(session) { } hideFromStack(assertSession); -function pushToStream(stream, data) { - // if (stream.writableEnded) return; - const queue = stream[bunHTTP2StreamReadQueue]; - if (queue.isEmpty()) { - if (stream.push(data)) return; - } - queue.push(data); +function pushToStream(stream, data) {; + stream.push(data); } enum StreamState { @@ -1551,7 +1545,6 @@ class Http2Stream extends Duplex { [bunHTTP2StreamStatus]: number = 0; rstCode: number | undefined = undefined; - [bunHTTP2StreamReadQueue]: Array = $createFIFO(); [bunHTTP2Headers]: any; [kInfoHeaders]: any; #sentTrailers: any; @@ -1772,18 +1765,11 @@ class Http2Stream extends Duplex { } } - _read(size) { - const queue = this[bunHTTP2StreamReadQueue]; - let chunk; - while ((chunk = queue.peek())) { - if (!this.push(chunk)) { - queue.shift(); - return; - } - queue.shift(); - } + _read(_size) { + // we always use the internal stream queue now } + end(chunk, encoding, callback) { const status = this[bunHTTP2StreamStatus];