Skip to content

Commit

Permalink
fix(http2) remove queue (#16573)
Browse files Browse the repository at this point in the history
Co-authored-by: Jarred Sumner <[email protected]>
  • Loading branch information
cirospaciari and Jarred-Sumner authored Jan 21, 2025
1 parent 5819fe4 commit e44e25e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/api/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
24 changes: 5 additions & 19 deletions src/js/node/http2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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::");
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -1551,7 +1545,6 @@ class Http2Stream extends Duplex {
[bunHTTP2StreamStatus]: number = 0;

rstCode: number | undefined = undefined;
[bunHTTP2StreamReadQueue]: Array<Buffer> = $createFIFO();
[bunHTTP2Headers]: any;
[kInfoHeaders]: any;
#sentTrailers: any;
Expand Down Expand Up @@ -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];

Expand Down

0 comments on commit e44e25e

Please sign in to comment.