Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/bun-uws/src/HttpContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ struct HttpContext {
auto *httpContextData = getSocketContextDataS(s);


if (httpResponseData->isConnectRequest && httpResponseData->socketData && httpContextData->onSocketDrain) {
if ((IsNodeHttp || httpResponseData->isConnectRequest) && httpResponseData->socketData && httpContextData->onSocketDrain) {
httpContextData->onSocketDrain(httpResponseData->socketData, SSL, (struct us_socket_t *) s);
}
/* Ask the developer to write data and return success (true) or failure (false), OR skip sending anything and return success (true). */
Expand Down
3 changes: 2 additions & 1 deletion src/js/ahead-of-time/node/_http_outgoing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// What the compiler reads in place of src/js/node/_http_outgoing.ts, which `bun run` evaluates. The two do the same.
// Written against that file with the SHA-256 7eb68379dcc85e37da343c90d1da52f21b0bd91937cea041c06b56a6db7551fc.
// Written against that file with the SHA-256 844b8c71bb274a66021c5d1bf7478198b9f0155beb008519d5a1618352888462.
// When that file changes, bring the change here and write the new hash: test/internal/second-texts-of-modules.test.ts.

// Hardcoded module "node:_http_outgoing"
Expand Down Expand Up @@ -2427,6 +2427,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, "_headerNames", {
});

export default {
kCorked,
kHighWaterMark,
kUniqueHeaders,
kOutHeaders,
Expand Down
395 changes: 362 additions & 33 deletions src/js/ahead-of-time/node/_http_server.ts

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/js/internal/streams/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const kIsReadable = Symbol.for("nodejs.stream.readable");
const kIsWritable = Symbol.for("nodejs.stream.writable");
const kIsDisturbed = Symbol.for("nodejs.stream.disturbed");

const kWriteOperation = Symbol("kWriteOperation");
const kWriteOperationEncoding = "bun:write-operation";
const kIsClosedPromise = Symbol.for("nodejs.webstream.isClosedPromise");
const kControllerErrorFunction = Symbol.for("nodejs.webstream.controllerErrorFunction");

Expand Down Expand Up @@ -390,6 +392,8 @@ function isErrored(stream) {
}

export default {
kWriteOperation,
kWriteOperationEncoding,
isDestroyed,
kIsDestroyed,
isDisturbed,
Expand Down
15 changes: 15 additions & 0 deletions src/js/internal/streams/writable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const { Stream } = require("internal/streams/legacy");
const destroyImpl = require("internal/streams/destroy");
const eos = require("internal/streams/end-of-stream");
const { addAbortSignal } = require("internal/streams/add-abort-signal");
const streamUtils = require("internal/streams/utils");
const kWriteOperation: typeof streamUtils.kWriteOperation = streamUtils.kWriteOperation;
const kWriteOperationEncoding = streamUtils.kWriteOperationEncoding;
const streamState = require("internal/streams/state");
const { WritableState, resetBuffer, isReadableState, isWritableState, flagsOf, addFlags, removeFlags, internals, nop } =
streamState;
Expand Down Expand Up @@ -230,6 +233,18 @@ function _write(stream: $Node.Writable, state: WritableState, chunk, encoding, c
return writeOrBuffer(stream, state, chunk, encoding, cb, 1);
}

// Internal byte-counted operations share the byte stream's queue and lifecycle.
Writable.prototype[kWriteOperation] = function (operation, callback) {
const state: WritableState = this._writableState;
const cb: WriteCallback = callback ?? nop;
if ((state[kState] & Flag.EndingOrDestroyed) !== 0) {
writeAfterEnd(this, state, cb);
return false;
}
state.pendingcb!++;
return writeOrBuffer(this, state, operation, kWriteOperationEncoding, cb, operation.length);
};

const writeBytes = function _write(stream: $Node.Writable, state: WritableState, chunk, encoding, cb: WriteCallback) {
if (!encoding) {
encoding = (state[kState] & Flag.DefaultUTF8Encoding) !== 0 ? "utf8" : state[kDefaultEncodingValue];
Expand Down
1 change: 1 addition & 0 deletions src/js/node/_http_outgoing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, "_headerNames", {
});

export default {
kCorked,
kHighWaterMark,
kUniqueHeaders,
kOutHeaders,
Expand Down
Loading
Loading