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
115 changes: 95 additions & 20 deletions .github/actions/deploy-docs-site/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,7 @@ var require_dispatcher_base = __commonJS({
}
get webSocketOptions() {
return {
maxFragments: this[kWebSocketOptions].maxFragments ?? 131072,
maxPayloadSize: this[kWebSocketOptions].maxPayloadSize ?? 128 * 1024 * 1024
};
}
Expand Down Expand Up @@ -5711,6 +5712,9 @@ var require_client_h1 = __commonJS({
var FastBuffer = Buffer[Symbol.species];
var addListener = util.addListener;
var removeAllListeners = util.removeAllListeners;
var kIdleSocketValidation = Symbol("kIdleSocketValidation");
var kIdleSocketValidationTimeout = Symbol("kIdleSocketValidationTimeout");
var kSocketUsed = Symbol("kSocketUsed");
var extractBody;
async function lazyllhttp() {
const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0;
Expand Down Expand Up @@ -5941,6 +5945,10 @@ var require_client_h1 = __commonJS({
if (socket.destroyed) {
return -1;
}
if (client[kRunning] === 0) {
util.destroy(socket, new SocketError("bad response", util.getSocketInfo(socket)));
return -1;
}
const request3 = client[kQueue][client[kRunningIdx]];
if (!request3) {
return -1;
Expand Down Expand Up @@ -6020,6 +6028,10 @@ var require_client_h1 = __commonJS({
if (socket.destroyed) {
return -1;
}
if (client[kRunning] === 0) {
util.destroy(socket, new SocketError("bad response", util.getSocketInfo(socket)));
return -1;
}
const request3 = client[kQueue][client[kRunningIdx]];
if (!request3) {
return -1;
Expand Down Expand Up @@ -6145,6 +6157,7 @@ var require_client_h1 = __commonJS({
}
request3.onComplete(headers);
client[kQueue][client[kRunningIdx]++] = null;
socket[kSocketUsed] = true;
if (socket[kWriting]) {
assert2(client[kRunning] === 0);
util.destroy(socket, new InformationalError("reset"));
Expand Down Expand Up @@ -6188,6 +6201,9 @@ var require_client_h1 = __commonJS({
socket[kWriting] = false;
socket[kReset2] = false;
socket[kBlocking] = false;
socket[kIdleSocketValidation] = 0;
socket[kIdleSocketValidationTimeout] = null;
socket[kSocketUsed] = false;
socket[kParser] = new Parser2(client, socket, llhttpInstance);
addListener(socket, "error", function(err) {
assert2(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID");
Expand Down Expand Up @@ -6223,6 +6239,7 @@ var require_client_h1 = __commonJS({
addListener(socket, "close", function() {
const client2 = this[kClient];
const parser2 = this[kParser];
clearIdleSocketValidation(this);
if (parser2) {
if (!this[kError] && parser2.statusCode && !parser2.shouldKeepAlive) {
this[kError] = parser2.finish() || this[kError];
Expand Down Expand Up @@ -6274,7 +6291,7 @@ var require_client_h1 = __commonJS({
return socket.destroyed;
},
busy(request3) {
if (socket[kWriting] || socket[kReset2] || socket[kBlocking]) {
if (socket[kWriting] || socket[kReset2] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) {
return true;
}
if (request3) {
Expand All @@ -6292,6 +6309,24 @@ var require_client_h1 = __commonJS({
}
};
}
function clearIdleSocketValidation(socket) {
if (socket[kIdleSocketValidationTimeout]) {
clearTimeout(socket[kIdleSocketValidationTimeout]);
socket[kIdleSocketValidationTimeout] = null;
}
socket[kIdleSocketValidation] = 0;
}
function scheduleIdleSocketValidation(client, socket) {
socket[kIdleSocketValidation] = 1;
socket[kIdleSocketValidationTimeout] = setTimeout(() => {
socket[kIdleSocketValidationTimeout] = null;
socket[kIdleSocketValidation] = 2;
if (client[kSocket] === socket && !socket.destroyed) {
client[kResume]();
}
}, 0);
socket[kIdleSocketValidationTimeout].unref?.();
}
function resumeH1(client) {
const socket = client[kSocket];
if (socket && !socket.destroyed) {
Expand All @@ -6304,6 +6339,29 @@ var require_client_h1 = __commonJS({
socket.ref();
socket[kNoRef] = false;
}
if (client[kRunning] === 0 && client[kPending] > 0 && socket[kSocketUsed]) {
if (socket[kIdleSocketValidation] === 0) {
scheduleIdleSocketValidation(client, socket);
socket[kParser].readMore();
if (socket.destroyed) {
return;
}
return;
}
if (socket[kIdleSocketValidation] === 1) {
socket[kParser].readMore();
if (socket.destroyed) {
return;
}
return;
}
}
if (client[kRunning] === 0) {
socket[kParser].readMore();
if (socket.destroyed) {
return;
}
}
if (client[kSize] === 0) {
if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) {
socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE);
Expand Down Expand Up @@ -6356,6 +6414,7 @@ var require_client_h1 = __commonJS({
process.emitWarning(new RequestContentLengthMismatchError());
}
const socket = client[kSocket];
clearIdleSocketValidation(socket);
const abort = (err) => {
if (request3.aborted || request3.completed) {
return;
Expand Down Expand Up @@ -16148,18 +16207,14 @@ var require_parse = __commonJS({
} else if (attributeNameLowercase === "httponly") {
cookieAttributeList.httpOnly = true;
} else if (attributeNameLowercase === "samesite") {
let enforcement = "Default";
const attributeValueLowercase = attributeValue.toLowerCase();
if (attributeValueLowercase.includes("none")) {
enforcement = "None";
}
if (attributeValueLowercase.includes("strict")) {
enforcement = "Strict";
if (attributeValueLowercase === "none") {
cookieAttributeList.sameSite = "None";
} else if (attributeValueLowercase === "strict") {
cookieAttributeList.sameSite = "Strict";
} else if (attributeValueLowercase === "lax") {
cookieAttributeList.sameSite = "Lax";
}
if (attributeValueLowercase.includes("lax")) {
enforcement = "Lax";
}
cookieAttributeList.sameSite = enforcement;
} else {
cookieAttributeList.unparsed ??= [];
cookieAttributeList.unparsed.push(`${attributeName}=${attributeValue}`);
Expand Down Expand Up @@ -17181,6 +17236,10 @@ var require_receiver = __commonJS({
var { closeWebSocketConnection } = require_connection();
var { PerMessageDeflate } = require_permessage_deflate();
var { MessageSizeExceededError } = require_errors();
function failWebsocketConnectionWithCode(ws, code, reason) {
closeWebSocketConnection(ws, code, reason, Buffer.byteLength(reason));
failWebsocketConnection(ws, reason);
}
var ByteParser = class extends Writable {
#buffers = [];
#fragmentsBytes = 0;
Expand All @@ -17192,16 +17251,19 @@ var require_receiver = __commonJS({
/** @type {Map<string, PerMessageDeflate>} */
#extensions;
/** @type {number} */
#maxFragments;
/** @type {number} */
#maxPayloadSize;
/**
* @param {import('./websocket').WebSocket} ws
* @param {Map<string, string>|null} extensions
* @param {{ maxPayloadSize?: number }} [options]
* @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
*/
constructor(ws, extensions, options = {}) {
super();
this.ws = ws;
this.#extensions = extensions == null ? /* @__PURE__ */ new Map() : extensions;
this.#maxFragments = options.maxFragments ?? 0;
this.#maxPayloadSize = options.maxPayloadSize ?? 0;
if (this.#extensions.has("permessage-deflate")) {
this.#extensions.set("permessage-deflate", new PerMessageDeflate(extensions, options));
Expand All @@ -17218,8 +17280,8 @@ var require_receiver = __commonJS({
this.run(callback);
}
#validatePayloadLength() {
if (this.#maxPayloadSize > 0 && !isControlFrame(this.#info.opcode) && this.#info.payloadLength > this.#maxPayloadSize) {
failWebsocketConnection(this.ws, "Payload size exceeds maximum allowed size");
if (this.#maxPayloadSize > 0 && !isControlFrame(this.#info.opcode) && this.#info.payloadLength + this.#fragmentsBytes > this.#maxPayloadSize) {
failWebsocketConnectionWithCode(this.ws, 1009, "Payload size exceeds maximum allowed size");
return false;
}
return true;
Expand Down Expand Up @@ -17335,9 +17397,11 @@ var require_receiver = __commonJS({
this.#state = parserStates.INFO;
} else {
if (!this.#info.compressed) {
this.writeFragments(body);
if (!this.writeFragments(body)) {
return;
}
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
failWebsocketConnection(this.ws, new MessageSizeExceededError().message);
failWebsocketConnectionWithCode(this.ws, 1009, new MessageSizeExceededError().message);
return;
}
if (!this.#info.fragmented && this.#info.fin) {
Expand All @@ -17350,12 +17414,15 @@ var require_receiver = __commonJS({
this.#info.fin,
(error2, data) => {
if (error2) {
failWebsocketConnection(this.ws, error2.message);
const code = error2 instanceof MessageSizeExceededError ? 1009 : 1007;
failWebsocketConnectionWithCode(this.ws, code, error2.message);
return;
}
if (!this.writeFragments(data)) {
return;
}
this.writeFragments(data);
if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
failWebsocketConnection(this.ws, new MessageSizeExceededError().message);
failWebsocketConnectionWithCode(this.ws, 1009, new MessageSizeExceededError().message);
return;
}
if (!this.#info.fin) {
Expand Down Expand Up @@ -17413,8 +17480,13 @@ var require_receiver = __commonJS({
return buffer;
}
writeFragments(fragment) {
if (this.#maxFragments > 0 && this.#fragments.length === this.#maxFragments) {
failWebsocketConnectionWithCode(this.ws, 1008, "Too many message fragments");
return false;
}
this.#fragmentsBytes += fragment.length;
this.#fragments.push(fragment);
return true;
}
consumeFragments() {
const fragments = this.#fragments;
Expand Down Expand Up @@ -17864,8 +17936,11 @@ var require_websocket = __commonJS({
*/
#onConnectionEstablished(response, parsedExtensions) {
this[kResponse] = response;
const maxPayloadSize = this[kController]?.dispatcher?.webSocketOptions?.maxPayloadSize;
const webSocketOptions = this[kController]?.dispatcher?.webSocketOptions;
const maxFragments = webSocketOptions?.maxFragments;
const maxPayloadSize = webSocketOptions?.maxPayloadSize;
const parser2 = new ByteParser(this, parsedExtensions, {
maxFragments,
maxPayloadSize
});
parser2.on("drain", onParserDrain);
Expand Down
Loading
Loading