From 9b1c1dd11e3503f7aeda3b69011ecdf6a6b0e8df Mon Sep 17 00:00:00 2001 From: Angular Robot Date: Thu, 10 Oct 2024 14:11:12 +0000 Subject: [PATCH] build: update all non-major dependencies --- .github/local-actions/branch-manager/main.js | 408 +++++++++++------- .github/local-actions/changelog/main.js | 408 +++++++++++------- .github/local-actions/labels-sync/main.js | 408 +++++++++++------- .github/local-actions/lock-closed/main.js | 408 +++++++++++------- .github/ng-renovate/package.json | 2 +- .github/ng-renovate/yarn.lock | 10 +- github-actions/bazel/setup/action.yml | 4 +- github-actions/branch-manager/main.js | 408 +++++++++++------- .../commit-message-based-labels/main.js | 408 +++++++++++------- github-actions/create-pr-for-changes/main.js | 408 +++++++++++------- github-actions/feature-request/main.js | 408 +++++++++++------- github-actions/google-internal-tests/main.js | 408 +++++++++++------- github-actions/org-file-sync/main.js | 408 +++++++++++------- github-actions/post-approval-changes/main.js | 408 +++++++++++------- github-actions/slash-commands/main.js | 408 +++++++++++------- github-actions/unified-status-check/main.js | 408 +++++++++++------- package.json | 2 +- yarn.lock | 68 ++- 18 files changed, 3343 insertions(+), 2047 deletions(-) diff --git a/.github/local-actions/branch-manager/main.js b/.github/local-actions/branch-manager/main.js index ed1e8614b..ff1e1490c 100644 --- a/.github/local-actions/branch-manager/main.js +++ b/.github/local-actions/branch-manager/main.js @@ -35200,6 +35200,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -35231,6 +35242,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -35617,7 +35629,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -36696,6 +36708,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -36704,6 +36832,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -36770,8 +36901,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -36780,7 +36912,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -36788,11 +36920,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -36800,16 +36933,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -36819,122 +36952,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -38942,13 +39004,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -38963,8 +39030,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -39383,9 +39450,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -39966,35 +40040,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -40007,9 +40081,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -40035,24 +40111,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -40129,7 +40208,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -40188,16 +40267,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -40236,7 +40315,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -40257,7 +40336,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -40301,7 +40380,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -40325,16 +40404,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -40347,7 +40426,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -40364,17 +40443,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -40391,8 +40470,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -40499,8 +40578,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -43098,8 +43177,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -44249,8 +44334,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context2 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -44552,6 +44637,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -47833,22 +47922,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/.github/local-actions/changelog/main.js b/.github/local-actions/changelog/main.js index 5afed590b..9ee39e547 100644 --- a/.github/local-actions/changelog/main.js +++ b/.github/local-actions/changelog/main.js @@ -19727,6 +19727,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19758,6 +19769,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20144,7 +20156,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21223,6 +21235,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21231,6 +21359,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21297,8 +21428,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21307,7 +21439,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21315,11 +21447,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21327,16 +21460,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21346,122 +21479,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23469,13 +23531,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23490,8 +23557,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23910,9 +23977,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24493,35 +24567,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24534,9 +24608,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24562,24 +24638,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24656,7 +24735,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24715,16 +24794,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24763,7 +24842,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24784,7 +24863,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24828,7 +24907,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24852,16 +24931,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24874,7 +24953,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24891,17 +24970,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24918,8 +24997,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25026,8 +25105,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27625,8 +27704,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28776,8 +28861,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context3 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29079,6 +29164,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32360,22 +32449,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/.github/local-actions/labels-sync/main.js b/.github/local-actions/labels-sync/main.js index bbbb8399f..744658eb7 100644 --- a/.github/local-actions/labels-sync/main.js +++ b/.github/local-actions/labels-sync/main.js @@ -19723,6 +19723,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19754,6 +19765,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20140,7 +20152,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21219,6 +21231,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21227,6 +21355,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21293,8 +21424,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21303,7 +21435,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21311,11 +21443,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21323,16 +21456,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21342,122 +21475,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23465,13 +23527,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23486,8 +23553,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23906,9 +23973,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24489,35 +24563,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24530,9 +24604,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24558,24 +24634,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24652,7 +24731,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24711,16 +24790,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24759,7 +24838,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24780,7 +24859,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24824,7 +24903,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24848,16 +24927,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24870,7 +24949,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24887,17 +24966,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24914,8 +24993,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25022,8 +25101,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27621,8 +27700,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28772,8 +28857,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context3 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29075,6 +29160,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32356,22 +32445,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/.github/local-actions/lock-closed/main.js b/.github/local-actions/lock-closed/main.js index ef3112892..41613824f 100644 --- a/.github/local-actions/lock-closed/main.js +++ b/.github/local-actions/lock-closed/main.js @@ -19723,6 +19723,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19754,6 +19765,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20140,7 +20152,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21219,6 +21231,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21227,6 +21355,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21293,8 +21424,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21303,7 +21435,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21311,11 +21443,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21323,16 +21456,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21342,122 +21475,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23465,13 +23527,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23486,8 +23553,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23906,9 +23973,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24489,35 +24563,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24530,9 +24604,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24558,24 +24634,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24652,7 +24731,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24711,16 +24790,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24759,7 +24838,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24780,7 +24859,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24824,7 +24903,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24848,16 +24927,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24870,7 +24949,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24887,17 +24966,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24914,8 +24993,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25022,8 +25101,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27621,8 +27700,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28772,8 +28857,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context3 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29075,6 +29160,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32356,22 +32445,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/.github/ng-renovate/package.json b/.github/ng-renovate/package.json index 3c7b2665f..47f45d2a4 100644 --- a/.github/ng-renovate/package.json +++ b/.github/ng-renovate/package.json @@ -3,6 +3,6 @@ "packageManager": "yarn@4.5.0", "type": "commonjs", "dependencies": { - "renovate": "38.114.0" + "renovate": "38.116.0" } } diff --git a/.github/ng-renovate/yarn.lock b/.github/ng-renovate/yarn.lock index 177dddd78..d4bd02d0e 100644 --- a/.github/ng-renovate/yarn.lock +++ b/.github/ng-renovate/yarn.lock @@ -5793,7 +5793,7 @@ __metadata: version: 0.0.0-use.local resolution: "ng-renovate@workspace:." dependencies: - renovate: "npm:38.114.0" + renovate: "npm:38.116.0" languageName: unknown linkType: soft @@ -6528,9 +6528,9 @@ __metadata: languageName: node linkType: hard -"renovate@npm:38.114.0": - version: 38.114.0 - resolution: "renovate@npm:38.114.0" +"renovate@npm:38.116.0": + version: 38.116.0 + resolution: "renovate@npm:38.116.0" dependencies: "@aws-sdk/client-codecommit": "npm:3.658.1" "@aws-sdk/client-ec2": "npm:3.658.1" @@ -6652,7 +6652,7 @@ __metadata: bin: renovate: dist/renovate.js renovate-config-validator: dist/config-validator.js - checksum: 10c0/7062b7aa2031d6cf4ba997b05bd3cfcd5b2db92105a97f6a8aed906696a694dc0818a41e48213d9eeaaf02b336953bed30e7dd4c5461b3838911ab62c03361f8 + checksum: 10c0/e8fd0a765097d4952e3279a0f0134e49d09c967e740bc493c90b7e261013c1aa4bd75b68accf29f84517ffbf50e712f0ed9d4e31a281535258ac472594b1b369 languageName: node linkType: hard diff --git a/github-actions/bazel/setup/action.yml b/github-actions/bazel/setup/action.yml index 9d5edcab0..9aa253bb0 100644 --- a/github-actions/bazel/setup/action.yml +++ b/github-actions/bazel/setup/action.yml @@ -13,7 +13,7 @@ runs: using: composite steps: - name: Configure action caching for bazel version downloaded by bazelisk - uses: actions/cache@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2 # v4.1.0 + uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1 with: path: | ~/.cache/bazelisk @@ -27,7 +27,7 @@ runs: shell: bash - name: Configure action caching for bazel repository cache - uses: actions/cache@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2 # v4.1.0 + uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1 with: # Note: Bazel repository cache is located in system locations and cannot use # a shared cache between different runner operating systems. diff --git a/github-actions/branch-manager/main.js b/github-actions/branch-manager/main.js index a91460607..95dbbc669 100644 --- a/github-actions/branch-manager/main.js +++ b/github-actions/branch-manager/main.js @@ -19723,6 +19723,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19754,6 +19765,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20140,7 +20152,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21219,6 +21231,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21227,6 +21355,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21293,8 +21424,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21303,7 +21435,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21311,11 +21443,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21323,16 +21456,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21342,122 +21475,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23465,13 +23527,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23486,8 +23553,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23906,9 +23973,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24489,35 +24563,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24530,9 +24604,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24558,24 +24634,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24652,7 +24731,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24711,16 +24790,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24759,7 +24838,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24780,7 +24859,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24824,7 +24903,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24848,16 +24927,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24870,7 +24949,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24887,17 +24966,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24914,8 +24993,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25022,8 +25101,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27621,8 +27700,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28772,8 +28857,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context3 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29075,6 +29160,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32356,22 +32445,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/github-actions/commit-message-based-labels/main.js b/github-actions/commit-message-based-labels/main.js index b9166cbe8..bb8fab2e7 100644 --- a/github-actions/commit-message-based-labels/main.js +++ b/github-actions/commit-message-based-labels/main.js @@ -19723,6 +19723,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19754,6 +19765,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20140,7 +20152,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21219,6 +21231,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21227,6 +21355,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21293,8 +21424,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21303,7 +21435,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21311,11 +21443,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21323,16 +21456,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21342,122 +21475,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23465,13 +23527,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23486,8 +23553,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23906,9 +23973,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24489,35 +24563,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24530,9 +24604,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24558,24 +24634,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24652,7 +24731,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24711,16 +24790,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24759,7 +24838,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24780,7 +24859,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24824,7 +24903,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24848,16 +24927,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24870,7 +24949,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24887,17 +24966,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24914,8 +24993,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25022,8 +25101,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27621,8 +27700,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28772,8 +28857,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context3 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29075,6 +29160,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32356,22 +32445,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/github-actions/create-pr-for-changes/main.js b/github-actions/create-pr-for-changes/main.js index 675499c22..58c32b0d2 100644 --- a/github-actions/create-pr-for-changes/main.js +++ b/github-actions/create-pr-for-changes/main.js @@ -19718,6 +19718,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19749,6 +19760,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20135,7 +20147,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21214,6 +21226,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21222,6 +21350,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21288,8 +21419,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21298,7 +21430,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21306,11 +21438,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21318,16 +21451,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21337,122 +21470,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23460,13 +23522,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23481,8 +23548,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23901,9 +23968,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24484,35 +24558,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24525,9 +24599,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24553,24 +24629,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24647,7 +24726,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24706,16 +24785,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24754,7 +24833,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24775,7 +24854,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24819,7 +24898,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24843,16 +24922,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24865,7 +24944,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24882,17 +24961,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24909,8 +24988,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25017,8 +25096,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27616,8 +27695,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28767,8 +28852,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context2 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29070,6 +29155,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32351,22 +32440,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/github-actions/feature-request/main.js b/github-actions/feature-request/main.js index efd684454..eb22f3024 100644 --- a/github-actions/feature-request/main.js +++ b/github-actions/feature-request/main.js @@ -19723,6 +19723,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19754,6 +19765,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20140,7 +20152,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21219,6 +21231,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21227,6 +21355,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21293,8 +21424,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21303,7 +21435,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21311,11 +21443,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21323,16 +21456,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21342,122 +21475,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23465,13 +23527,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23486,8 +23553,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23906,9 +23973,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24489,35 +24563,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24530,9 +24604,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24558,24 +24634,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24652,7 +24731,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24711,16 +24790,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24759,7 +24838,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24780,7 +24859,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24824,7 +24903,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24848,16 +24927,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24870,7 +24949,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24887,17 +24966,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24914,8 +24993,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25022,8 +25101,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27621,8 +27700,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28772,8 +28857,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context3 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29075,6 +29160,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32356,22 +32445,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/github-actions/google-internal-tests/main.js b/github-actions/google-internal-tests/main.js index 6a9169d29..77af23baa 100644 --- a/github-actions/google-internal-tests/main.js +++ b/github-actions/google-internal-tests/main.js @@ -19722,6 +19722,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19753,6 +19764,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20139,7 +20151,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21218,6 +21230,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21226,6 +21354,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21292,8 +21423,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21302,7 +21434,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21310,11 +21442,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21322,16 +21455,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21341,122 +21474,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23464,13 +23526,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23485,8 +23552,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23905,9 +23972,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24488,35 +24562,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24529,9 +24603,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24557,24 +24633,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24651,7 +24730,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24710,16 +24789,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24758,7 +24837,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24779,7 +24858,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24823,7 +24902,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24847,16 +24926,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24869,7 +24948,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24886,17 +24965,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24913,8 +24992,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25021,8 +25100,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27620,8 +27699,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28771,8 +28856,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context2 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29074,6 +29159,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32355,22 +32444,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/github-actions/org-file-sync/main.js b/github-actions/org-file-sync/main.js index 83fa13ece..8094403ae 100644 --- a/github-actions/org-file-sync/main.js +++ b/github-actions/org-file-sync/main.js @@ -19723,6 +19723,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19754,6 +19765,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20140,7 +20152,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21219,6 +21231,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21227,6 +21355,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21293,8 +21424,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21303,7 +21435,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21311,11 +21443,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21323,16 +21456,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21342,122 +21475,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23465,13 +23527,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23486,8 +23553,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23906,9 +23973,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24489,35 +24563,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24530,9 +24604,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24558,24 +24634,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24652,7 +24731,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24711,16 +24790,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24759,7 +24838,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24780,7 +24859,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24824,7 +24903,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24848,16 +24927,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24870,7 +24949,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24887,17 +24966,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24914,8 +24993,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25022,8 +25101,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27621,8 +27700,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28772,8 +28857,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context3 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29075,6 +29160,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32356,22 +32445,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/github-actions/post-approval-changes/main.js b/github-actions/post-approval-changes/main.js index d5ab3bac6..65dadba6e 100644 --- a/github-actions/post-approval-changes/main.js +++ b/github-actions/post-approval-changes/main.js @@ -19723,6 +19723,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19754,6 +19765,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20140,7 +20152,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21219,6 +21231,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21227,6 +21355,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21293,8 +21424,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21303,7 +21435,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21311,11 +21443,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21323,16 +21456,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21342,122 +21475,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23465,13 +23527,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23486,8 +23553,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23906,9 +23973,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24489,35 +24563,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24530,9 +24604,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24558,24 +24634,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24652,7 +24731,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24711,16 +24790,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24759,7 +24838,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24780,7 +24859,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24824,7 +24903,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24848,16 +24927,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24870,7 +24949,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24887,17 +24966,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24914,8 +24993,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25022,8 +25101,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27621,8 +27700,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28772,8 +28857,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context3 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29075,6 +29160,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32356,22 +32445,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/github-actions/slash-commands/main.js b/github-actions/slash-commands/main.js index 94fd49323..1826072ae 100644 --- a/github-actions/slash-commands/main.js +++ b/github-actions/slash-commands/main.js @@ -19726,6 +19726,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19757,6 +19768,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20143,7 +20155,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21222,6 +21234,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21230,6 +21358,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21296,8 +21427,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21306,7 +21438,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21314,11 +21446,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21326,16 +21459,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21345,122 +21478,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23468,13 +23530,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23489,8 +23556,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23909,9 +23976,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24492,35 +24566,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24533,9 +24607,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24561,24 +24637,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24655,7 +24734,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24714,16 +24793,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24762,7 +24841,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24783,7 +24862,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24827,7 +24906,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24851,16 +24930,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24873,7 +24952,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24890,17 +24969,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24917,8 +24996,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25025,8 +25104,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27624,8 +27703,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28775,8 +28860,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context4 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29078,6 +29163,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32359,22 +32448,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/github-actions/unified-status-check/main.js b/github-actions/unified-status-check/main.js index 0088580af..fa9e3e28d 100644 --- a/github-actions/unified-status-check/main.js +++ b/github-actions/unified-status-check/main.js @@ -19723,6 +19723,17 @@ var require_errors2 = __commonJS({ this.headers = headers; } }; + var ResponseError = class extends UndiciError { + constructor(message, code, { headers, data }) { + super(message); + this.name = "ResponseError"; + this.message = message || "Response error"; + this.code = "UND_ERR_RESPONSE"; + this.statusCode = code; + this.data = data; + this.headers = headers; + } + }; var SecureProxyConnectionError = class extends UndiciError { constructor(cause, message, options) { super(message, { cause, ...options ?? {} }); @@ -19754,6 +19765,7 @@ var require_errors2 = __commonJS({ BalancedPoolMissingUpstreamError, ResponseExceededMaxSizeError, RequestRetryError, + ResponseError, SecureProxyConnectionError }; } @@ -20140,7 +20152,7 @@ var require_util8 = __commonJS({ if (!host) { return null; } - assert.strictEqual(typeof host, "string"); + assert(typeof host === "string"); const servername = getHostname(host); if (net.isIP(servername)) { return ""; @@ -21219,6 +21231,122 @@ var require_dispatcher_base2 = __commonJS({ } }); +// +var require_timers2 = __commonJS({ + ""(exports, module) { + "use strict"; + var fastNow = 0; + var RESOLUTION_MS = 1e3; + var TICK_MS = (RESOLUTION_MS >> 1) - 1; + var fastNowTimeout; + var kFastTimer = Symbol("kFastTimer"); + var fastTimers = []; + var NOT_IN_LIST = -2; + var TO_BE_CLEARED = -1; + var PENDING = 0; + var ACTIVE = 1; + function onTick() { + fastNow += TICK_MS; + let idx = 0; + let len = fastTimers.length; + while (idx < len) { + const timer = fastTimers[idx]; + if (timer._state === PENDING) { + timer._idleStart = fastNow - TICK_MS; + timer._state = ACTIVE; + } else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) { + timer._state = TO_BE_CLEARED; + timer._idleStart = -1; + timer._onTimeout(timer._timerArg); + } + if (timer._state === TO_BE_CLEARED) { + timer._state = NOT_IN_LIST; + if (--len !== 0) { + fastTimers[idx] = fastTimers[len]; + } + } else { + ++idx; + } + } + fastTimers.length = len; + if (fastTimers.length !== 0) { + refreshTimeout(); + } + } + function refreshTimeout() { + if (fastNowTimeout) { + fastNowTimeout.refresh(); + } else { + clearTimeout(fastNowTimeout); + fastNowTimeout = setTimeout(onTick, TICK_MS); + if (fastNowTimeout.unref) { + fastNowTimeout.unref(); + } + } + } + var FastTimer = class { + [kFastTimer] = true; + _state = NOT_IN_LIST; + _idleTimeout = -1; + _idleStart = -1; + _onTimeout; + _timerArg; + constructor(callback, delay, arg) { + this._onTimeout = callback; + this._idleTimeout = delay; + this._timerArg = arg; + this.refresh(); + } + refresh() { + if (this._state === NOT_IN_LIST) { + fastTimers.push(this); + } + if (!fastNowTimeout || fastTimers.length === 1) { + refreshTimeout(); + } + this._state = PENDING; + } + clear() { + this._state = TO_BE_CLEARED; + this._idleStart = -1; + } + }; + module.exports = { + setTimeout(callback, delay, arg) { + return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg); + }, + clearTimeout(timeout) { + if (timeout[kFastTimer]) { + timeout.clear(); + } else { + clearTimeout(timeout); + } + }, + setFastTimeout(callback, delay, arg) { + return new FastTimer(callback, delay, arg); + }, + clearFastTimeout(timeout) { + timeout.clear(); + }, + now() { + return fastNow; + }, + tick(delay = 0) { + fastNow += delay - RESOLUTION_MS + 1; + onTick(); + onTick(); + }, + reset() { + fastNow = 0; + fastTimers.length = 0; + clearTimeout(fastNowTimeout); + fastNowTimeout = null; + }, + kFastTimer + }; + } +}); + // var require_connect2 = __commonJS({ ""(exports, module) { @@ -21227,6 +21355,9 @@ var require_connect2 = __commonJS({ var assert = __require("node:assert"); var util = require_util8(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); + var timers = require_timers2(); + function noop2() { + } var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21293,8 +21424,9 @@ var require_connect2 = __commonJS({ } servername = servername || options.servername || util.getServerName(host) || null; const sessionKey = servername || hostname; - const session = customSession || sessionCache.get(sessionKey) || null; assert(sessionKey); + const session = customSession || sessionCache.get(sessionKey) || null; + port = port || 443; socket = tls.connect({ highWaterMark: 16384, ...options, @@ -21303,7 +21435,7 @@ var require_connect2 = __commonJS({ localAddress, ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"], socket: httpSocket, - port: port || 443, + port, host: hostname }); socket.on("session", function(session2) { @@ -21311,11 +21443,12 @@ var require_connect2 = __commonJS({ }); } else { assert(!httpSocket, "httpSocket can only be sent on TLS update"); + port = port || 80; socket = net.connect({ highWaterMark: 64 * 1024, ...options, localAddress, - port: port || 80, + port, host: hostname }); } @@ -21323,16 +21456,16 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const cancelTimeout = setupTimeout(() => onConnectTimeout(socket), timeout); + const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; cb(null, this); } }).on("error", function(err) { - cancelTimeout(); + queueMicrotask(clearConnectTimeout); if (callback) { const cb = callback; callback = null; @@ -21342,122 +21475,51 @@ var require_connect2 = __commonJS({ return socket; }; } - function setupTimeout(onConnectTimeout2, timeout) { - if (!timeout) { - return () => { - }; + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; } let s1 = null; let s2 = null; - const timeoutId = setTimeout(() => { + const fastTimer = timers.setFastTimeout(() => { s1 = setImmediate(() => { - if (process.platform === "win32") { - s2 = setImmediate(() => onConnectTimeout2()); - } else { - onConnectTimeout2(); - } + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); }); - }, timeout); + }, opts.timeout); return () => { - clearTimeout(timeoutId); + timers.clearFastTimeout(fastTimer); clearImmediate(s1); clearImmediate(s2); }; - } - function onConnectTimeout(socket) { + } : (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + onConnectTimeout(socketWeakRef.deref(), opts); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + }; + }; + function onConnectTimeout(socket, opts) { let message = "Connect Timeout Error"; if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")})`; + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; } + message += ` timeout: ${opts.timeout}ms)`; util.destroy(socket, new ConnectTimeoutError(message)); } module.exports = buildConnector; } }); -// -var require_timers2 = __commonJS({ - ""(exports, module) { - "use strict"; - var TICK_MS = 499; - var fastNow = Date.now(); - var fastNowTimeout; - var fastTimers = []; - function onTimeout() { - fastNow = Date.now(); - let len = fastTimers.length; - let idx = 0; - while (idx < len) { - const timer = fastTimers[idx]; - if (timer.state === 0) { - timer.state = fastNow + timer.delay - TICK_MS; - } else if (timer.state > 0 && fastNow >= timer.state) { - timer.state = -1; - timer.callback(timer.opaque); - } - if (timer.state === -1) { - timer.state = -2; - if (idx !== len - 1) { - fastTimers[idx] = fastTimers.pop(); - } else { - fastTimers.pop(); - } - len -= 1; - } else { - idx += 1; - } - } - if (fastTimers.length > 0) { - refreshTimeout(); - } - } - function refreshTimeout() { - if (fastNowTimeout == null ? void 0 : fastNowTimeout.refresh) { - fastNowTimeout.refresh(); - } else { - clearTimeout(fastNowTimeout); - fastNowTimeout = setTimeout(onTimeout, TICK_MS); - if (fastNowTimeout.unref) { - fastNowTimeout.unref(); - } - } - } - var Timeout = class { - constructor(callback, delay, opaque) { - this.callback = callback; - this.delay = delay; - this.opaque = opaque; - this.state = -2; - this.refresh(); - } - refresh() { - if (this.state === -2) { - fastTimers.push(this); - if (!fastNowTimeout || fastTimers.length === 1) { - refreshTimeout(); - } - } - this.state = 0; - } - clear() { - this.state = -1; - } - }; - module.exports = { - setTimeout(callback, delay, opaque) { - return delay <= 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque); - }, - clearTimeout(timeout) { - if (timeout instanceof Timeout) { - timeout.clear(); - } else { - clearTimeout(timeout); - } - } - }; - } -}); - // var require_utils3 = __commonJS({ ""(exports) { @@ -23465,13 +23527,18 @@ var require_util9 = __commonJS({ return contentRange; } var InflateStream = class extends Transform { + #zlibOptions; + constructor(zlibOptions) { + super(); + this.#zlibOptions = zlibOptions; + } _transform(chunk, encoding, callback) { if (!this._inflateStream) { if (chunk.length === 0) { callback(); return; } - this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate() : zlib.createInflateRaw(); + this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(this.#zlibOptions) : zlib.createInflateRaw(this.#zlibOptions); this._inflateStream.on("data", this.push.bind(this)); this._inflateStream.on("end", () => this.push(null)); this._inflateStream.on("error", (err) => this.destroy(err)); @@ -23486,8 +23553,8 @@ var require_util9 = __commonJS({ callback(); } }; - function createInflate() { - return new InflateStream(); + function createInflate(zlibOptions) { + return new InflateStream(zlibOptions); } function extractMimeType(headers) { let charset = null; @@ -23906,9 +23973,16 @@ var require_formdata_parser = __commonJS({ const boundary = Buffer.from(`--${boundaryString}`, "utf8"); const entryList = []; const position = { position: 0 }; - if (input[0] === 13 && input[1] === 10) { + while (input[position.position] === 13 && input[position.position + 1] === 10) { position.position += 2; } + let trailing = input.length; + while (input[trailing - 1] === 10 && input[trailing - 2] === 13) { + trailing -= 2; + } + if (trailing !== input.length) { + input = input.subarray(0, trailing); + } while (true) { if (input.subarray(position.position, position.position + boundary.length).equals(boundary)) { position.position += boundary.length; @@ -24489,35 +24563,35 @@ var require_client_h1 = __commonJS({ return 0; }, wasm_on_status: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_begin: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageBegin() || 0; }, wasm_on_header_field: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_header_value: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0; }, wasm_on_body: (p, at, len) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); const start = at - currentBufferPtr + currentBufferRef.byteOffset; return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0; }, wasm_on_message_complete: (p) => { - assert.strictEqual(currentParser.ptr, p); + assert(currentParser.ptr === p); return currentParser.onMessageComplete() || 0; } } @@ -24530,9 +24604,11 @@ var require_client_h1 = __commonJS({ var currentBufferRef = null; var currentBufferSize = 0; var currentBufferPtr = null; - var TIMEOUT_HEADERS = 1; - var TIMEOUT_BODY = 2; - var TIMEOUT_IDLE = 3; + var USE_NATIVE_TIMER = 0; + var USE_FAST_TIMER = 1; + var TIMEOUT_HEADERS = 2 | USE_FAST_TIMER; + var TIMEOUT_BODY = 4 | USE_FAST_TIMER; + var TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER; var Parser = class { constructor(client, socket, { exports: exports2 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); @@ -24558,24 +24634,27 @@ var require_client_h1 = __commonJS({ this.connection = ""; this.maxResponseSize = client[kMaxResponseSize]; } - setTimeout(value, type) { - this.timeoutType = type; - if (value !== this.timeoutValue) { - timers.clearTimeout(this.timeout); - if (value) { - this.timeout = timers.setTimeout(onParserTimeout, value, this); - if (this.timeout.unref) { + setTimeout(delay, type) { + if (delay !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) { + if (this.timeout) { + timers.clearTimeout(this.timeout); + this.timeout = null; + } + if (delay) { + if (type & USE_FAST_TIMER) { + this.timeout = timers.setFastTimeout(onParserTimeout, delay, new WeakRef(this)); + } else { + this.timeout = setTimeout(onParserTimeout, delay, new WeakRef(this)); this.timeout.unref(); } - } else { - this.timeout = null; } - this.timeoutValue = value; + this.timeoutValue = delay; } else if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); } } + this.timeoutType = type; } resume() { if (this.socket.destroyed || !this.paused) { @@ -24652,7 +24731,7 @@ var require_client_h1 = __commonJS({ assert(currentParser == null); this.llhttp.llhttp_free(this.ptr); this.ptr = null; - timers.clearTimeout(this.timeout); + this.timeout && timers.clearTimeout(this.timeout); this.timeout = null; this.timeoutValue = null; this.timeoutType = null; @@ -24711,16 +24790,16 @@ var require_client_h1 = __commonJS({ onUpgrade(head) { const { upgrade, client, socket, headers, statusCode } = this; assert(upgrade); - const request2 = client[kQueue][client[kRunningIdx]]; - assert(request2); + assert(client[kSocket] === socket); assert(!socket.destroyed); - assert(socket === client[kSocket]); assert(!this.paused); + assert((headers.length & 1) === 0); + const request2 = client[kQueue][client[kRunningIdx]]; + assert(request2); assert(request2.upgrade || request2.method === "CONNECT"); this.statusCode = null; this.statusText = ""; this.shouldKeepAlive = null; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; socket.unshift(head); @@ -24759,7 +24838,7 @@ var require_client_h1 = __commonJS({ util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); return -1; } - assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS); + assert(this.timeoutType === TIMEOUT_HEADERS); this.statusCode = statusCode; this.shouldKeepAlive = shouldKeepAlive || request2.method === "HEAD" && !socket[kReset] && this.connection.toLowerCase() === "keep-alive"; if (this.statusCode >= 200) { @@ -24780,7 +24859,7 @@ var require_client_h1 = __commonJS({ this.upgrade = true; return 2; } - assert(this.headers.length % 2 === 0); + assert((this.headers.length & 1) === 0); this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { @@ -24824,7 +24903,7 @@ var require_client_h1 = __commonJS({ } const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert.strictEqual(this.timeoutType, TIMEOUT_BODY); + assert(this.timeoutType === TIMEOUT_BODY); if (this.timeout) { if (this.timeout.refresh) { this.timeout.refresh(); @@ -24848,16 +24927,16 @@ var require_client_h1 = __commonJS({ if (upgrade) { return; } + assert(statusCode >= 100); + assert((this.headers.length & 1) === 0); const request2 = client[kQueue][client[kRunningIdx]]; assert(request2); - assert(statusCode >= 100); this.statusCode = null; this.statusText = ""; this.bytesRead = 0; this.contentLength = ""; this.keepAlive = ""; this.connection = ""; - assert(this.headers.length % 2 === 0); this.headers = []; this.headersSize = 0; if (statusCode < 200) { @@ -24870,7 +24949,7 @@ var require_client_h1 = __commonJS({ request2.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { - assert.strictEqual(client[kRunning], 0); + assert(client[kRunning] === 0); util.destroy(socket, new InformationalError("reset")); return constants.ERROR.PAUSED; } else if (!shouldKeepAlive) { @@ -24887,17 +24966,17 @@ var require_client_h1 = __commonJS({ } }; function onParserTimeout(parser) { - const { socket, timeoutType, client } = parser; + const { socket, timeoutType, client, paused } = parser.deref(); if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { - assert(!parser.paused, "cannot be paused while waiting for headers"); + assert(!paused, "cannot be paused while waiting for headers"); util.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { - if (!parser.paused) { + if (!paused) { util.destroy(socket, new BodyTimeoutError()); } - } else if (timeoutType === TIMEOUT_IDLE) { + } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); util.destroy(socket, new InformationalError("socket idle timeout")); } @@ -24914,8 +24993,8 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; socket[kParser] = new Parser(client, socket, llhttpInstance); addListener(socket, "error", function(err) { - const parser = this[kParser]; assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); + const parser = this[kParser]; if (err.code === "ECONNRESET" && parser.statusCode && !parser.shouldKeepAlive) { parser.onMessageComplete(); return; @@ -25022,8 +25101,8 @@ var require_client_h1 = __commonJS({ socket[kNoRef] = false; } if (client[kSize] === 0) { - if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { - socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE); + if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) { + socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE); } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { @@ -27621,8 +27700,14 @@ var require_retry_handler = __commonJS({ } if (this.resume != null) { this.resume = null; - if (statusCode !== 206) { - return true; + if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) { + this.abort( + new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, { + headers, + data: { count: this.retryCount } + }) + ); + return false; } const contentRange = parseRangeHeader(headers["content-range"]); if (!contentRange) { @@ -28772,8 +28857,8 @@ var require_api_upgrade2 = __commonJS({ throw new SocketError("bad upgrade", null); } onUpgrade(statusCode, rawHeaders, socket) { + assert(statusCode === 101); const { callback, opaque, context: context3 } = this; - assert.strictEqual(statusCode, 101); removeSignal(this); this.callback = null; const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); @@ -29075,6 +29160,10 @@ var require_mock_utils2 = __commonJS({ function getResponseData2(data) { if (Buffer.isBuffer(data)) { return data; + } else if (data instanceof Uint8Array) { + return data; + } else if (data instanceof ArrayBuffer) { + return data; } else if (typeof data === "object") { return JSON.stringify(data); } else { @@ -32356,22 +32445,31 @@ var require_fetch2 = __commonJS({ finishFlush: zlib.constants.Z_SYNC_FLUSH })); } else if (coding === "deflate") { - decoders.push(createInflate()); + decoders.push(createInflate({ + flush: zlib.constants.Z_SYNC_FLUSH, + finishFlush: zlib.constants.Z_SYNC_FLUSH + })); } else if (coding === "br") { - decoders.push(zlib.createBrotliDecompress()); + decoders.push(zlib.createBrotliDecompress({ + flush: zlib.constants.BROTLI_OPERATION_FLUSH, + finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH + })); } else { decoders.length = 0; break; } } } + const onError = this.onError.bind(this); resolve({ status, statusText, headersList, - body: decoders.length ? pipeline(this.body, ...decoders, () => { - }) : this.body.on("error", () => { - }) + body: decoders.length ? pipeline(this.body, ...decoders, (err) => { + if (err) { + this.onError(err); + } + }).on("error", onError) : this.body.on("error", onError) }); return true; }, diff --git a/package.json b/package.json index 518cda4d8..279cfc984 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "tmp": "^0.2.1", "true-case-path": "^2.2.1", "tslib": "^2.5.2", - "typescript": "5.6.2", + "typescript": "5.6.3", "uuid": "^10.0.0", "yargs": "^17.0.0" }, diff --git a/yarn.lock b/yarn.lock index 6f2c5bd97..f01eecd7b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -428,7 +428,7 @@ __metadata: tslint: "npm:^6.1.3" tsx: "npm:^4.15.7" typed-graphqlify: "npm:^3.1.1" - typescript: "npm:5.6.2" + typescript: "npm:5.6.3" undici: "npm:^6.19.8" uuid: "npm:^10.0.0" wait-on: "npm:^8.0.0" @@ -780,8 +780,8 @@ __metadata: linkType: hard "@babel/core@npm:^7.12.3, @babel/core@npm:^7.16.0, @babel/core@npm:^7.23.9": - version: 7.25.7 - resolution: "@babel/core@npm:7.25.7" + version: 7.25.8 + resolution: "@babel/core@npm:7.25.8" dependencies: "@ampproject/remapping": "npm:^2.2.0" "@babel/code-frame": "npm:^7.25.7" @@ -789,16 +789,16 @@ __metadata: "@babel/helper-compilation-targets": "npm:^7.25.7" "@babel/helper-module-transforms": "npm:^7.25.7" "@babel/helpers": "npm:^7.25.7" - "@babel/parser": "npm:^7.25.7" + "@babel/parser": "npm:^7.25.8" "@babel/template": "npm:^7.25.7" "@babel/traverse": "npm:^7.25.7" - "@babel/types": "npm:^7.25.7" + "@babel/types": "npm:^7.25.8" convert-source-map: "npm:^2.0.0" debug: "npm:^4.1.0" gensync: "npm:^1.0.0-beta.2" json5: "npm:^2.2.3" semver: "npm:^6.3.1" - checksum: 10c0/dad20af39624086afc3a0910bd97ae712c9ad0e9dda09fc5da93876e8ea1802b63ddd81c44f4aa8a9834db46de801eaab1ce9b81ab54b4fe907ae052c24de136 + checksum: 10c0/8411ea506e6f7c8a39ab5c1524b00589fa3b087edb47389708f7fe07170929192171734666e3ea10b95a951643a531a6d09eedfe071572c9ea28516646265086 languageName: node linkType: hard @@ -982,6 +982,17 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:^7.25.8": + version: 7.25.8 + resolution: "@babel/parser@npm:7.25.8" + dependencies: + "@babel/types": "npm:^7.25.8" + bin: + parser: ./bin/babel-parser.js + checksum: 10c0/a1a13845b7e8dda4c970791814a4bbf60004969882f18f470e260ad822d2e1f8941948f851e9335895563610f240fa6c98481ce8019865e469502bbf21daafa4 + languageName: node + linkType: hard + "@babel/plugin-proposal-async-generator-functions@npm:^7.20.1": version: 7.20.7 resolution: "@babel/plugin-proposal-async-generator-functions@npm:7.20.7" @@ -1055,6 +1066,17 @@ __metadata: languageName: node linkType: hard +"@babel/types@npm:^7.25.8": + version: 7.25.8 + resolution: "@babel/types@npm:7.25.8" + dependencies: + "@babel/helper-string-parser": "npm:^7.25.7" + "@babel/helper-validator-identifier": "npm:^7.25.7" + to-fast-properties: "npm:^2.0.0" + checksum: 10c0/55ca2d6df6426c98db2769ce884ce5e9de83a512ea2dd7bcf56c811984dc14351cacf42932a723630c5afcff2455809323decd645820762182f10b7b5252b59f + languageName: node + linkType: hard + "@bazel/bazelisk@npm:^1.11.0": version: 1.22.0 resolution: "@bazel/bazelisk@npm:1.22.0" @@ -3010,13 +3032,13 @@ __metadata: linkType: hard "@lezer/javascript@npm:^1.4.9": - version: 1.4.18 - resolution: "@lezer/javascript@npm:1.4.18" + version: 1.4.19 + resolution: "@lezer/javascript@npm:1.4.19" dependencies: "@lezer/common": "npm:^1.2.0" "@lezer/highlight": "npm:^1.1.3" "@lezer/lr": "npm:^1.3.0" - checksum: 10c0/3aedc368f8ed124e9563e7732453fcbfae0093ffe1406e1f8e4c1f8205a037b52f6c7772959a6f18030422414b7d71dbfc80437782f1aadafc5f88649f436b98 + checksum: 10c0/04cb49e028dd03b07009e3bef8f1e99ead84ee5ee1f3210371a07b2d8af1e8f5fabf6316115d10f8f44b5db6efa0af713d9fe20ab2c99c83d9abe778a3eb3369 languageName: node linkType: hard @@ -8333,8 +8355,8 @@ __metadata: linkType: hard "firebase-tools@npm:^13.0.0": - version: 13.21.0 - resolution: "firebase-tools@npm:13.21.0" + version: 13.22.0 + resolution: "firebase-tools@npm:13.22.0" dependencies: "@electric-sql/pglite": "npm:^0.2.0" "@google-cloud/cloud-sql-connector": "npm:^1.3.3" @@ -8406,7 +8428,7 @@ __metadata: yaml: "npm:^2.4.1" bin: firebase: lib/bin/firebase.js - checksum: 10c0/51bd6d02d42e949ba273a59dd69378ca26fae24a4cb35d49d2fa24bde379815ad1e54d4832fcacf5612171201acd29a9aa234c286c66489a6d374ad7a8044aa0 + checksum: 10c0/3be6ee75e5170488650fb479f365e09bb94381492234c907843a26e18e0df2e271a0f39c3fe99945836428f68116805e76a6822a1ce376f37c0842c2f3cc3904 languageName: node linkType: hard @@ -15145,13 +15167,13 @@ __metadata: languageName: node linkType: hard -"typescript@npm:5.6.2": - version: 5.6.2 - resolution: "typescript@npm:5.6.2" +"typescript@npm:5.6.3": + version: 5.6.3 + resolution: "typescript@npm:5.6.3" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/3ed8297a8c7c56b7fec282532503d1ac795239d06e7c4966b42d4330c6cf433a170b53bcf93a130a7f14ccc5235de5560df4f1045eb7f3550b46ebed16d3c5e5 + checksum: 10c0/44f61d3fb15c35359bc60399cb8127c30bae554cd555b8e2b46d68fa79d680354b83320ad419ff1b81a0bdf324197b29affe6cc28988cd6a74d4ac60c94f9799 languageName: node linkType: hard @@ -15165,13 +15187,13 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@npm%3A5.6.2#optional!builtin": - version: 5.6.2 - resolution: "typescript@patch:typescript@npm%3A5.6.2#optional!builtin::version=5.6.2&hash=8c6c40" +"typescript@patch:typescript@npm%3A5.6.3#optional!builtin": + version: 5.6.3 + resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin::version=5.6.3&hash=8c6c40" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/94eb47e130d3edd964b76da85975601dcb3604b0c848a36f63ac448d0104e93819d94c8bdf6b07c00120f2ce9c05256b8b6092d23cf5cf1c6fa911159e4d572f + checksum: 10c0/7c9d2e07c81226d60435939618c91ec2ff0b75fbfa106eec3430f0fcf93a584bc6c73176676f532d78c3594fe28a54b36eb40b3d75593071a7ec91301533ace7 languageName: node linkType: hard @@ -15224,9 +15246,9 @@ __metadata: linkType: hard "undici@npm:^6.19.8": - version: 6.19.8 - resolution: "undici@npm:6.19.8" - checksum: 10c0/07fd8520bce7e34ea29c07ef0de27b734183042cdb4e2f1262cd1fb9b755a6b04ff2471040395dfb1770fb7786069a97c5178bcf706b80a34075994f46feb37c + version: 6.20.0 + resolution: "undici@npm:6.20.0" + checksum: 10c0/b74a6e4dcdfc3a6e7f5eab77c24f598c5a8664091797dc4940f86e1ed27e5dc9bef390aa1ecf53f20c7ec0e8809bc3d1518a8c3c560fa5972a6a325d628765be languageName: node linkType: hard