From ca84b0dd6c5145f19a8b0ab4f96aee34c49c8492 Mon Sep 17 00:00:00 2001 From: Angular Robot Date: Wed, 2 Apr 2025 16:09:52 +0000 Subject: [PATCH] build: update all non-major dependencies --- .github/local-actions/branch-manager/main.js | 433 +++++++++++------- .github/local-actions/labels-sync/main.js | 433 +++++++++++------- .github/local-actions/lock-closed/main.js | 433 +++++++++++------- github-actions/branch-manager/main.js | 433 +++++++++++------- .../commit-message-based-labels/main.js | 433 +++++++++++------- github-actions/create-pr-for-changes/main.js | 433 +++++++++++------- github-actions/feature-request/main.js | 433 +++++++++++------- github-actions/google-internal-tests/main.js | 433 +++++++++++------- github-actions/org-file-sync/main.js | 433 +++++++++++------- github-actions/post-approval-changes/main.js | 433 +++++++++++------- github-actions/unified-status-check/main.js | 433 +++++++++++------- yarn.lock | 42 +- 12 files changed, 2947 insertions(+), 1858 deletions(-) diff --git a/.github/local-actions/branch-manager/main.js b/.github/local-actions/branch-manager/main.js index 3ad301882..a67fe151a 100644 --- a/.github/local-actions/branch-manager/main.js +++ b/.github/local-actions/branch-manager/main.js @@ -35134,6 +35134,122 @@ var require_symbols6 = __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_errors2 = __commonJS({ ""(exports, module) { @@ -35612,7 +35728,8 @@ var require_util8 = __commonJS({ var nodeUtil = __require("node:util"); var { stringify } = __require("node:querystring"); var { EventEmitter: EE } = __require("node:events"); - var { InvalidArgumentError } = require_errors2(); + var timers = require_timers2(); + var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); var { headerNameLowerCasedRecord } = require_constants7(); var { tree } = require_tree(); var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v)); @@ -35627,6 +35744,8 @@ var require_util8 = __commonJS({ yield* this[kBody]; } }; + function noop2() { + } function wrapRequestBody(body) { if (isStream(body)) { if (bodyLength(body) === 0) { @@ -36052,6 +36171,50 @@ var require_util8 = __commonJS({ client.emit("error", err2); } } + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + let s2 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + clearImmediate(s2); + }; + } : (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) { + if (socket == null) { + return; + } + let message = "Connect Timeout Error"; + if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; + } + message += ` timeout: ${opts.timeout}ms)`; + destroy(socket, new ConnectTimeoutError(message)); + } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; var normalizedMethodRecordsBase = { @@ -36118,7 +36281,8 @@ var require_util8 = __commonJS({ nodeMajor, nodeMinor, safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]), - wrapRequestBody + wrapRequestBody, + setupConnectTimeout }; } }); @@ -36996,122 +37160,6 @@ 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) { @@ -37119,10 +37167,7 @@ var require_connect2 = __commonJS({ var net = __require("node:net"); var assert2 = __require("node:assert"); var util = require_util8(); - var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); - var timers = require_timers2(); - function noop2() { - } + var { InvalidArgumentError } = require_errors2(); var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -37221,7 +37266,7 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); + const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { @@ -37240,50 +37285,6 @@ var require_connect2 = __commonJS({ return socket; }; } - var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { - if (!opts.timeout) { - return noop2; - } - let s1 = null; - let s2 = null; - const fastTimer = timers.setFastTimeout(() => { - s1 = setImmediate(() => { - s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); - }); - }, opts.timeout); - return () => { - timers.clearFastTimeout(fastTimer); - clearImmediate(s1); - clearImmediate(s2); - }; - } : (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) { - if (socket == null) { - return; - } - let message = "Connect Timeout Error"; - if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - 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; } }); @@ -41730,6 +41731,7 @@ var require_client_h2 = __commonJS({ } assert2(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); + client.emit("connectionError", client[kUrl], [client], err); client[kResume](); } function onHttp2SessionClose() { @@ -43792,6 +43794,101 @@ var require_retry_agent = __commonJS({ } }); +// +var require_h2c_client = __commonJS({ + ""(exports, module) { + "use strict"; + var { connect } = __require("node:net"); + var { kClose, kDestroy } = require_symbols6(); + var { InvalidArgumentError } = require_errors2(); + var util = require_util8(); + var Client = require_client2(); + var DispatcherBase = require_dispatcher_base2(); + var H2CClient = class extends DispatcherBase { + #client = null; + constructor(origin, clientOpts) { + super(); + if (typeof origin === "string") { + origin = new URL(origin); + } + if (origin.protocol !== "http:") { + throw new InvalidArgumentError( + "h2c-client: Only h2c protocol is supported" + ); + } + const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {}; + let defaultMaxConcurrentStreams = 100; + let defaultPipelining = 100; + if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) { + defaultMaxConcurrentStreams = maxConcurrentStreams; + } + if (pipelining != null && Number.isInteger(pipelining) && pipelining > 0) { + defaultPipelining = pipelining; + } + if (defaultPipelining > defaultMaxConcurrentStreams) { + throw new InvalidArgumentError( + "h2c-client: pipelining cannot be greater than maxConcurrentStreams" + ); + } + this.#client = new Client(origin, { + ...opts, + connect: this.#buildConnector(connect2), + maxConcurrentStreams: defaultMaxConcurrentStreams, + pipelining: defaultPipelining, + allowH2: true + }); + } + #buildConnector(connectOpts) { + return (opts, callback) => { + const timeout = (connectOpts == null ? void 0 : connectOpts.connectOpts) ?? 1e4; + const { hostname, port, pathname } = opts; + const socket = connect({ + ...opts, + host: hostname, + port, + pathname + }); + if (opts.keepAlive == null || opts.keepAlive) { + const keepAliveInitialDelay = opts.keepAliveInitialDelay == null ? 6e4 : opts.keepAliveInitialDelay; + socket.setKeepAlive(true, keepAliveInitialDelay); + } + socket.alpnProtocol = "h2"; + const clearConnectTimeout = util.setupConnectTimeout( + new WeakRef(socket), + { timeout, hostname, port } + ); + socket.setNoDelay(true).once("connect", function() { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(null, this); + } + }).on("error", function(err) { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(err); + } + }); + return socket; + }; + } + dispatch(opts, handler2) { + return this.#client.dispatch(opts, handler2); + } + async [kClose]() { + await this.#client.close(); + } + async [kDestroy]() { + await this.#client.destroy(); + } + }; + module.exports = H2CClient; + } +}); + // var require_readable2 = __commonJS({ ""(exports, module) { @@ -54197,6 +54294,7 @@ var require_undici2 = __commonJS({ var ProxyAgent = require_proxy_agent2(); var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); + var H2CClient = require_h2c_client(); var errors = require_errors2(); var util = require_util8(); var { InvalidArgumentError } = errors; @@ -54220,6 +54318,7 @@ var require_undici2 = __commonJS({ module.exports.ProxyAgent = ProxyAgent; module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module.exports.RetryAgent = RetryAgent; + module.exports.H2CClient = H2CClient; module.exports.RetryHandler = RetryHandler; module.exports.DecoratorHandler = DecoratorHandler; module.exports.RedirectHandler = RedirectHandler; diff --git a/.github/local-actions/labels-sync/main.js b/.github/local-actions/labels-sync/main.js index 5c052146d..3563eb3ae 100644 --- a/.github/local-actions/labels-sync/main.js +++ b/.github/local-actions/labels-sync/main.js @@ -19545,6 +19545,122 @@ var require_symbols6 = __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_errors2 = __commonJS({ ""(exports, module) { @@ -20023,7 +20139,8 @@ var require_util8 = __commonJS({ var nodeUtil = __require("node:util"); var { stringify } = __require("node:querystring"); var { EventEmitter: EE } = __require("node:events"); - var { InvalidArgumentError } = require_errors2(); + var timers = require_timers2(); + var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); var { headerNameLowerCasedRecord } = require_constants6(); var { tree } = require_tree(); var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v)); @@ -20038,6 +20155,8 @@ var require_util8 = __commonJS({ yield* this[kBody]; } }; + function noop2() { + } function wrapRequestBody(body) { if (isStream(body)) { if (bodyLength(body) === 0) { @@ -20463,6 +20582,50 @@ var require_util8 = __commonJS({ client.emit("error", err2); } } + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + let s2 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + clearImmediate(s2); + }; + } : (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) { + if (socket == null) { + return; + } + let message = "Connect Timeout Error"; + if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; + } + message += ` timeout: ${opts.timeout}ms)`; + destroy(socket, new ConnectTimeoutError(message)); + } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; var normalizedMethodRecordsBase = { @@ -20529,7 +20692,8 @@ var require_util8 = __commonJS({ nodeMajor, nodeMinor, safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]), - wrapRequestBody + wrapRequestBody, + setupConnectTimeout }; } }); @@ -21407,122 +21571,6 @@ 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) { @@ -21530,10 +21578,7 @@ var require_connect2 = __commonJS({ var net = __require("node:net"); var assert = __require("node:assert"); var util = require_util8(); - var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); - var timers = require_timers2(); - function noop2() { - } + var { InvalidArgumentError } = require_errors2(); var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21632,7 +21677,7 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); + const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { @@ -21651,50 +21696,6 @@ var require_connect2 = __commonJS({ return socket; }; } - var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { - if (!opts.timeout) { - return noop2; - } - let s1 = null; - let s2 = null; - const fastTimer = timers.setFastTimeout(() => { - s1 = setImmediate(() => { - s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); - }); - }, opts.timeout); - return () => { - timers.clearFastTimeout(fastTimer); - clearImmediate(s1); - clearImmediate(s2); - }; - } : (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) { - if (socket == null) { - return; - } - let message = "Connect Timeout Error"; - if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - 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; } }); @@ -26141,6 +26142,7 @@ var require_client_h2 = __commonJS({ } assert(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); + client.emit("connectionError", client[kUrl], [client], err); client[kResume](); } function onHttp2SessionClose() { @@ -28203,6 +28205,101 @@ var require_retry_agent = __commonJS({ } }); +// +var require_h2c_client = __commonJS({ + ""(exports, module) { + "use strict"; + var { connect } = __require("node:net"); + var { kClose, kDestroy } = require_symbols6(); + var { InvalidArgumentError } = require_errors2(); + var util = require_util8(); + var Client = require_client2(); + var DispatcherBase = require_dispatcher_base2(); + var H2CClient = class extends DispatcherBase { + #client = null; + constructor(origin, clientOpts) { + super(); + if (typeof origin === "string") { + origin = new URL(origin); + } + if (origin.protocol !== "http:") { + throw new InvalidArgumentError( + "h2c-client: Only h2c protocol is supported" + ); + } + const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {}; + let defaultMaxConcurrentStreams = 100; + let defaultPipelining = 100; + if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) { + defaultMaxConcurrentStreams = maxConcurrentStreams; + } + if (pipelining != null && Number.isInteger(pipelining) && pipelining > 0) { + defaultPipelining = pipelining; + } + if (defaultPipelining > defaultMaxConcurrentStreams) { + throw new InvalidArgumentError( + "h2c-client: pipelining cannot be greater than maxConcurrentStreams" + ); + } + this.#client = new Client(origin, { + ...opts, + connect: this.#buildConnector(connect2), + maxConcurrentStreams: defaultMaxConcurrentStreams, + pipelining: defaultPipelining, + allowH2: true + }); + } + #buildConnector(connectOpts) { + return (opts, callback) => { + const timeout = (connectOpts == null ? void 0 : connectOpts.connectOpts) ?? 1e4; + const { hostname, port, pathname } = opts; + const socket = connect({ + ...opts, + host: hostname, + port, + pathname + }); + if (opts.keepAlive == null || opts.keepAlive) { + const keepAliveInitialDelay = opts.keepAliveInitialDelay == null ? 6e4 : opts.keepAliveInitialDelay; + socket.setKeepAlive(true, keepAliveInitialDelay); + } + socket.alpnProtocol = "h2"; + const clearConnectTimeout = util.setupConnectTimeout( + new WeakRef(socket), + { timeout, hostname, port } + ); + socket.setNoDelay(true).once("connect", function() { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(null, this); + } + }).on("error", function(err) { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(err); + } + }); + return socket; + }; + } + dispatch(opts, handler2) { + return this.#client.dispatch(opts, handler2); + } + async [kClose]() { + await this.#client.close(); + } + async [kDestroy]() { + await this.#client.destroy(); + } + }; + module.exports = H2CClient; + } +}); + // var require_readable2 = __commonJS({ ""(exports, module) { @@ -38608,6 +38705,7 @@ var require_undici2 = __commonJS({ var ProxyAgent = require_proxy_agent2(); var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); + var H2CClient = require_h2c_client(); var errors = require_errors2(); var util = require_util8(); var { InvalidArgumentError } = errors; @@ -38631,6 +38729,7 @@ var require_undici2 = __commonJS({ module.exports.ProxyAgent = ProxyAgent; module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module.exports.RetryAgent = RetryAgent; + module.exports.H2CClient = H2CClient; module.exports.RetryHandler = RetryHandler; module.exports.DecoratorHandler = DecoratorHandler; module.exports.RedirectHandler = RedirectHandler; diff --git a/.github/local-actions/lock-closed/main.js b/.github/local-actions/lock-closed/main.js index 772f36ec1..1332309ba 100644 --- a/.github/local-actions/lock-closed/main.js +++ b/.github/local-actions/lock-closed/main.js @@ -19545,6 +19545,122 @@ var require_symbols6 = __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_errors2 = __commonJS({ ""(exports, module) { @@ -20023,7 +20139,8 @@ var require_util8 = __commonJS({ var nodeUtil = __require("node:util"); var { stringify } = __require("node:querystring"); var { EventEmitter: EE } = __require("node:events"); - var { InvalidArgumentError } = require_errors2(); + var timers = require_timers2(); + var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); var { headerNameLowerCasedRecord } = require_constants6(); var { tree } = require_tree(); var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v)); @@ -20038,6 +20155,8 @@ var require_util8 = __commonJS({ yield* this[kBody]; } }; + function noop2() { + } function wrapRequestBody(body) { if (isStream(body)) { if (bodyLength(body) === 0) { @@ -20463,6 +20582,50 @@ var require_util8 = __commonJS({ client.emit("error", err2); } } + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + let s2 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + clearImmediate(s2); + }; + } : (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) { + if (socket == null) { + return; + } + let message = "Connect Timeout Error"; + if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; + } + message += ` timeout: ${opts.timeout}ms)`; + destroy(socket, new ConnectTimeoutError(message)); + } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; var normalizedMethodRecordsBase = { @@ -20529,7 +20692,8 @@ var require_util8 = __commonJS({ nodeMajor, nodeMinor, safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]), - wrapRequestBody + wrapRequestBody, + setupConnectTimeout }; } }); @@ -21407,122 +21571,6 @@ 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) { @@ -21530,10 +21578,7 @@ var require_connect2 = __commonJS({ var net = __require("node:net"); var assert = __require("node:assert"); var util = require_util8(); - var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); - var timers = require_timers2(); - function noop2() { - } + var { InvalidArgumentError } = require_errors2(); var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21632,7 +21677,7 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); + const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { @@ -21651,50 +21696,6 @@ var require_connect2 = __commonJS({ return socket; }; } - var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { - if (!opts.timeout) { - return noop2; - } - let s1 = null; - let s2 = null; - const fastTimer = timers.setFastTimeout(() => { - s1 = setImmediate(() => { - s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); - }); - }, opts.timeout); - return () => { - timers.clearFastTimeout(fastTimer); - clearImmediate(s1); - clearImmediate(s2); - }; - } : (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) { - if (socket == null) { - return; - } - let message = "Connect Timeout Error"; - if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - 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; } }); @@ -26141,6 +26142,7 @@ var require_client_h2 = __commonJS({ } assert(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); + client.emit("connectionError", client[kUrl], [client], err); client[kResume](); } function onHttp2SessionClose() { @@ -28203,6 +28205,101 @@ var require_retry_agent = __commonJS({ } }); +// +var require_h2c_client = __commonJS({ + ""(exports, module) { + "use strict"; + var { connect } = __require("node:net"); + var { kClose, kDestroy } = require_symbols6(); + var { InvalidArgumentError } = require_errors2(); + var util = require_util8(); + var Client = require_client2(); + var DispatcherBase = require_dispatcher_base2(); + var H2CClient = class extends DispatcherBase { + #client = null; + constructor(origin, clientOpts) { + super(); + if (typeof origin === "string") { + origin = new URL(origin); + } + if (origin.protocol !== "http:") { + throw new InvalidArgumentError( + "h2c-client: Only h2c protocol is supported" + ); + } + const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {}; + let defaultMaxConcurrentStreams = 100; + let defaultPipelining = 100; + if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) { + defaultMaxConcurrentStreams = maxConcurrentStreams; + } + if (pipelining != null && Number.isInteger(pipelining) && pipelining > 0) { + defaultPipelining = pipelining; + } + if (defaultPipelining > defaultMaxConcurrentStreams) { + throw new InvalidArgumentError( + "h2c-client: pipelining cannot be greater than maxConcurrentStreams" + ); + } + this.#client = new Client(origin, { + ...opts, + connect: this.#buildConnector(connect2), + maxConcurrentStreams: defaultMaxConcurrentStreams, + pipelining: defaultPipelining, + allowH2: true + }); + } + #buildConnector(connectOpts) { + return (opts, callback) => { + const timeout = (connectOpts == null ? void 0 : connectOpts.connectOpts) ?? 1e4; + const { hostname, port, pathname } = opts; + const socket = connect({ + ...opts, + host: hostname, + port, + pathname + }); + if (opts.keepAlive == null || opts.keepAlive) { + const keepAliveInitialDelay = opts.keepAliveInitialDelay == null ? 6e4 : opts.keepAliveInitialDelay; + socket.setKeepAlive(true, keepAliveInitialDelay); + } + socket.alpnProtocol = "h2"; + const clearConnectTimeout = util.setupConnectTimeout( + new WeakRef(socket), + { timeout, hostname, port } + ); + socket.setNoDelay(true).once("connect", function() { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(null, this); + } + }).on("error", function(err) { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(err); + } + }); + return socket; + }; + } + dispatch(opts, handler2) { + return this.#client.dispatch(opts, handler2); + } + async [kClose]() { + await this.#client.close(); + } + async [kDestroy]() { + await this.#client.destroy(); + } + }; + module.exports = H2CClient; + } +}); + // var require_readable2 = __commonJS({ ""(exports, module) { @@ -38608,6 +38705,7 @@ var require_undici2 = __commonJS({ var ProxyAgent = require_proxy_agent2(); var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); + var H2CClient = require_h2c_client(); var errors = require_errors2(); var util = require_util8(); var { InvalidArgumentError } = errors; @@ -38631,6 +38729,7 @@ var require_undici2 = __commonJS({ module.exports.ProxyAgent = ProxyAgent; module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module.exports.RetryAgent = RetryAgent; + module.exports.H2CClient = H2CClient; module.exports.RetryHandler = RetryHandler; module.exports.DecoratorHandler = DecoratorHandler; module.exports.RedirectHandler = RedirectHandler; diff --git a/github-actions/branch-manager/main.js b/github-actions/branch-manager/main.js index fede3619a..2cb149c0b 100644 --- a/github-actions/branch-manager/main.js +++ b/github-actions/branch-manager/main.js @@ -19545,6 +19545,122 @@ var require_symbols6 = __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_errors2 = __commonJS({ ""(exports, module) { @@ -20023,7 +20139,8 @@ var require_util8 = __commonJS({ var nodeUtil = __require("node:util"); var { stringify } = __require("node:querystring"); var { EventEmitter: EE } = __require("node:events"); - var { InvalidArgumentError } = require_errors2(); + var timers = require_timers2(); + var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); var { headerNameLowerCasedRecord } = require_constants6(); var { tree } = require_tree(); var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v)); @@ -20038,6 +20155,8 @@ var require_util8 = __commonJS({ yield* this[kBody]; } }; + function noop2() { + } function wrapRequestBody(body) { if (isStream(body)) { if (bodyLength(body) === 0) { @@ -20463,6 +20582,50 @@ var require_util8 = __commonJS({ client.emit("error", err2); } } + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + let s2 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + clearImmediate(s2); + }; + } : (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) { + if (socket == null) { + return; + } + let message = "Connect Timeout Error"; + if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; + } + message += ` timeout: ${opts.timeout}ms)`; + destroy(socket, new ConnectTimeoutError(message)); + } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; var normalizedMethodRecordsBase = { @@ -20529,7 +20692,8 @@ var require_util8 = __commonJS({ nodeMajor, nodeMinor, safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]), - wrapRequestBody + wrapRequestBody, + setupConnectTimeout }; } }); @@ -21407,122 +21571,6 @@ 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) { @@ -21530,10 +21578,7 @@ var require_connect2 = __commonJS({ var net = __require("node:net"); var assert = __require("node:assert"); var util = require_util8(); - var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); - var timers = require_timers2(); - function noop2() { - } + var { InvalidArgumentError } = require_errors2(); var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21632,7 +21677,7 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); + const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { @@ -21651,50 +21696,6 @@ var require_connect2 = __commonJS({ return socket; }; } - var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { - if (!opts.timeout) { - return noop2; - } - let s1 = null; - let s2 = null; - const fastTimer = timers.setFastTimeout(() => { - s1 = setImmediate(() => { - s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); - }); - }, opts.timeout); - return () => { - timers.clearFastTimeout(fastTimer); - clearImmediate(s1); - clearImmediate(s2); - }; - } : (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) { - if (socket == null) { - return; - } - let message = "Connect Timeout Error"; - if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - 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; } }); @@ -26141,6 +26142,7 @@ var require_client_h2 = __commonJS({ } assert(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); + client.emit("connectionError", client[kUrl], [client], err); client[kResume](); } function onHttp2SessionClose() { @@ -28203,6 +28205,101 @@ var require_retry_agent = __commonJS({ } }); +// +var require_h2c_client = __commonJS({ + ""(exports, module) { + "use strict"; + var { connect } = __require("node:net"); + var { kClose, kDestroy } = require_symbols6(); + var { InvalidArgumentError } = require_errors2(); + var util = require_util8(); + var Client = require_client2(); + var DispatcherBase = require_dispatcher_base2(); + var H2CClient = class extends DispatcherBase { + #client = null; + constructor(origin, clientOpts) { + super(); + if (typeof origin === "string") { + origin = new URL(origin); + } + if (origin.protocol !== "http:") { + throw new InvalidArgumentError( + "h2c-client: Only h2c protocol is supported" + ); + } + const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {}; + let defaultMaxConcurrentStreams = 100; + let defaultPipelining = 100; + if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) { + defaultMaxConcurrentStreams = maxConcurrentStreams; + } + if (pipelining != null && Number.isInteger(pipelining) && pipelining > 0) { + defaultPipelining = pipelining; + } + if (defaultPipelining > defaultMaxConcurrentStreams) { + throw new InvalidArgumentError( + "h2c-client: pipelining cannot be greater than maxConcurrentStreams" + ); + } + this.#client = new Client(origin, { + ...opts, + connect: this.#buildConnector(connect2), + maxConcurrentStreams: defaultMaxConcurrentStreams, + pipelining: defaultPipelining, + allowH2: true + }); + } + #buildConnector(connectOpts) { + return (opts, callback) => { + const timeout = (connectOpts == null ? void 0 : connectOpts.connectOpts) ?? 1e4; + const { hostname, port, pathname } = opts; + const socket = connect({ + ...opts, + host: hostname, + port, + pathname + }); + if (opts.keepAlive == null || opts.keepAlive) { + const keepAliveInitialDelay = opts.keepAliveInitialDelay == null ? 6e4 : opts.keepAliveInitialDelay; + socket.setKeepAlive(true, keepAliveInitialDelay); + } + socket.alpnProtocol = "h2"; + const clearConnectTimeout = util.setupConnectTimeout( + new WeakRef(socket), + { timeout, hostname, port } + ); + socket.setNoDelay(true).once("connect", function() { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(null, this); + } + }).on("error", function(err) { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(err); + } + }); + return socket; + }; + } + dispatch(opts, handler2) { + return this.#client.dispatch(opts, handler2); + } + async [kClose]() { + await this.#client.close(); + } + async [kDestroy]() { + await this.#client.destroy(); + } + }; + module.exports = H2CClient; + } +}); + // var require_readable2 = __commonJS({ ""(exports, module) { @@ -38608,6 +38705,7 @@ var require_undici2 = __commonJS({ var ProxyAgent = require_proxy_agent2(); var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); + var H2CClient = require_h2c_client(); var errors = require_errors2(); var util = require_util8(); var { InvalidArgumentError } = errors; @@ -38631,6 +38729,7 @@ var require_undici2 = __commonJS({ module.exports.ProxyAgent = ProxyAgent; module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module.exports.RetryAgent = RetryAgent; + module.exports.H2CClient = H2CClient; module.exports.RetryHandler = RetryHandler; module.exports.DecoratorHandler = DecoratorHandler; module.exports.RedirectHandler = RedirectHandler; diff --git a/github-actions/commit-message-based-labels/main.js b/github-actions/commit-message-based-labels/main.js index c18e69c43..ae224fabc 100644 --- a/github-actions/commit-message-based-labels/main.js +++ b/github-actions/commit-message-based-labels/main.js @@ -19545,6 +19545,122 @@ var require_symbols6 = __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_errors2 = __commonJS({ ""(exports, module) { @@ -20023,7 +20139,8 @@ var require_util8 = __commonJS({ var nodeUtil = __require("node:util"); var { stringify } = __require("node:querystring"); var { EventEmitter: EE } = __require("node:events"); - var { InvalidArgumentError } = require_errors2(); + var timers = require_timers2(); + var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); var { headerNameLowerCasedRecord } = require_constants6(); var { tree } = require_tree(); var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v)); @@ -20038,6 +20155,8 @@ var require_util8 = __commonJS({ yield* this[kBody]; } }; + function noop2() { + } function wrapRequestBody(body) { if (isStream(body)) { if (bodyLength(body) === 0) { @@ -20463,6 +20582,50 @@ var require_util8 = __commonJS({ client.emit("error", err2); } } + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + let s2 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + clearImmediate(s2); + }; + } : (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) { + if (socket == null) { + return; + } + let message = "Connect Timeout Error"; + if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; + } + message += ` timeout: ${opts.timeout}ms)`; + destroy(socket, new ConnectTimeoutError(message)); + } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; var normalizedMethodRecordsBase = { @@ -20529,7 +20692,8 @@ var require_util8 = __commonJS({ nodeMajor, nodeMinor, safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]), - wrapRequestBody + wrapRequestBody, + setupConnectTimeout }; } }); @@ -21407,122 +21571,6 @@ 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) { @@ -21530,10 +21578,7 @@ var require_connect2 = __commonJS({ var net = __require("node:net"); var assert = __require("node:assert"); var util = require_util8(); - var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); - var timers = require_timers2(); - function noop2() { - } + var { InvalidArgumentError } = require_errors2(); var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21632,7 +21677,7 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); + const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { @@ -21651,50 +21696,6 @@ var require_connect2 = __commonJS({ return socket; }; } - var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { - if (!opts.timeout) { - return noop2; - } - let s1 = null; - let s2 = null; - const fastTimer = timers.setFastTimeout(() => { - s1 = setImmediate(() => { - s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); - }); - }, opts.timeout); - return () => { - timers.clearFastTimeout(fastTimer); - clearImmediate(s1); - clearImmediate(s2); - }; - } : (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) { - if (socket == null) { - return; - } - let message = "Connect Timeout Error"; - if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - 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; } }); @@ -26141,6 +26142,7 @@ var require_client_h2 = __commonJS({ } assert(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); + client.emit("connectionError", client[kUrl], [client], err); client[kResume](); } function onHttp2SessionClose() { @@ -28203,6 +28205,101 @@ var require_retry_agent = __commonJS({ } }); +// +var require_h2c_client = __commonJS({ + ""(exports, module) { + "use strict"; + var { connect } = __require("node:net"); + var { kClose, kDestroy } = require_symbols6(); + var { InvalidArgumentError } = require_errors2(); + var util = require_util8(); + var Client = require_client2(); + var DispatcherBase = require_dispatcher_base2(); + var H2CClient = class extends DispatcherBase { + #client = null; + constructor(origin, clientOpts) { + super(); + if (typeof origin === "string") { + origin = new URL(origin); + } + if (origin.protocol !== "http:") { + throw new InvalidArgumentError( + "h2c-client: Only h2c protocol is supported" + ); + } + const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {}; + let defaultMaxConcurrentStreams = 100; + let defaultPipelining = 100; + if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) { + defaultMaxConcurrentStreams = maxConcurrentStreams; + } + if (pipelining != null && Number.isInteger(pipelining) && pipelining > 0) { + defaultPipelining = pipelining; + } + if (defaultPipelining > defaultMaxConcurrentStreams) { + throw new InvalidArgumentError( + "h2c-client: pipelining cannot be greater than maxConcurrentStreams" + ); + } + this.#client = new Client(origin, { + ...opts, + connect: this.#buildConnector(connect2), + maxConcurrentStreams: defaultMaxConcurrentStreams, + pipelining: defaultPipelining, + allowH2: true + }); + } + #buildConnector(connectOpts) { + return (opts, callback) => { + const timeout = (connectOpts == null ? void 0 : connectOpts.connectOpts) ?? 1e4; + const { hostname, port, pathname } = opts; + const socket = connect({ + ...opts, + host: hostname, + port, + pathname + }); + if (opts.keepAlive == null || opts.keepAlive) { + const keepAliveInitialDelay = opts.keepAliveInitialDelay == null ? 6e4 : opts.keepAliveInitialDelay; + socket.setKeepAlive(true, keepAliveInitialDelay); + } + socket.alpnProtocol = "h2"; + const clearConnectTimeout = util.setupConnectTimeout( + new WeakRef(socket), + { timeout, hostname, port } + ); + socket.setNoDelay(true).once("connect", function() { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(null, this); + } + }).on("error", function(err) { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(err); + } + }); + return socket; + }; + } + dispatch(opts, handler2) { + return this.#client.dispatch(opts, handler2); + } + async [kClose]() { + await this.#client.close(); + } + async [kDestroy]() { + await this.#client.destroy(); + } + }; + module.exports = H2CClient; + } +}); + // var require_readable2 = __commonJS({ ""(exports, module) { @@ -38608,6 +38705,7 @@ var require_undici2 = __commonJS({ var ProxyAgent = require_proxy_agent2(); var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); + var H2CClient = require_h2c_client(); var errors = require_errors2(); var util = require_util8(); var { InvalidArgumentError } = errors; @@ -38631,6 +38729,7 @@ var require_undici2 = __commonJS({ module.exports.ProxyAgent = ProxyAgent; module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module.exports.RetryAgent = RetryAgent; + module.exports.H2CClient = H2CClient; module.exports.RetryHandler = RetryHandler; module.exports.DecoratorHandler = DecoratorHandler; module.exports.RedirectHandler = RedirectHandler; diff --git a/github-actions/create-pr-for-changes/main.js b/github-actions/create-pr-for-changes/main.js index 88c991018..a5e7eec10 100644 --- a/github-actions/create-pr-for-changes/main.js +++ b/github-actions/create-pr-for-changes/main.js @@ -19545,6 +19545,122 @@ var require_symbols6 = __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_errors2 = __commonJS({ ""(exports, module) { @@ -20023,7 +20139,8 @@ var require_util8 = __commonJS({ var nodeUtil = __require("node:util"); var { stringify } = __require("node:querystring"); var { EventEmitter: EE } = __require("node:events"); - var { InvalidArgumentError } = require_errors2(); + var timers = require_timers2(); + var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); var { headerNameLowerCasedRecord } = require_constants6(); var { tree } = require_tree(); var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v)); @@ -20038,6 +20155,8 @@ var require_util8 = __commonJS({ yield* this[kBody]; } }; + function noop2() { + } function wrapRequestBody(body) { if (isStream(body)) { if (bodyLength(body) === 0) { @@ -20463,6 +20582,50 @@ var require_util8 = __commonJS({ client.emit("error", err2); } } + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + let s2 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + clearImmediate(s2); + }; + } : (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) { + if (socket == null) { + return; + } + let message = "Connect Timeout Error"; + if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; + } + message += ` timeout: ${opts.timeout}ms)`; + destroy(socket, new ConnectTimeoutError(message)); + } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; var normalizedMethodRecordsBase = { @@ -20529,7 +20692,8 @@ var require_util8 = __commonJS({ nodeMajor, nodeMinor, safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]), - wrapRequestBody + wrapRequestBody, + setupConnectTimeout }; } }); @@ -21407,122 +21571,6 @@ 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) { @@ -21530,10 +21578,7 @@ var require_connect2 = __commonJS({ var net = __require("node:net"); var assert2 = __require("node:assert"); var util = require_util8(); - var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); - var timers = require_timers2(); - function noop2() { - } + var { InvalidArgumentError } = require_errors2(); var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21632,7 +21677,7 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); + const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { @@ -21651,50 +21696,6 @@ var require_connect2 = __commonJS({ return socket; }; } - var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { - if (!opts.timeout) { - return noop2; - } - let s1 = null; - let s2 = null; - const fastTimer = timers.setFastTimeout(() => { - s1 = setImmediate(() => { - s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); - }); - }, opts.timeout); - return () => { - timers.clearFastTimeout(fastTimer); - clearImmediate(s1); - clearImmediate(s2); - }; - } : (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) { - if (socket == null) { - return; - } - let message = "Connect Timeout Error"; - if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - 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; } }); @@ -26141,6 +26142,7 @@ var require_client_h2 = __commonJS({ } assert2(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); + client.emit("connectionError", client[kUrl], [client], err); client[kResume](); } function onHttp2SessionClose() { @@ -28203,6 +28205,101 @@ var require_retry_agent = __commonJS({ } }); +// +var require_h2c_client = __commonJS({ + ""(exports, module) { + "use strict"; + var { connect } = __require("node:net"); + var { kClose, kDestroy } = require_symbols6(); + var { InvalidArgumentError } = require_errors2(); + var util = require_util8(); + var Client = require_client2(); + var DispatcherBase = require_dispatcher_base2(); + var H2CClient = class extends DispatcherBase { + #client = null; + constructor(origin, clientOpts) { + super(); + if (typeof origin === "string") { + origin = new URL(origin); + } + if (origin.protocol !== "http:") { + throw new InvalidArgumentError( + "h2c-client: Only h2c protocol is supported" + ); + } + const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {}; + let defaultMaxConcurrentStreams = 100; + let defaultPipelining = 100; + if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) { + defaultMaxConcurrentStreams = maxConcurrentStreams; + } + if (pipelining != null && Number.isInteger(pipelining) && pipelining > 0) { + defaultPipelining = pipelining; + } + if (defaultPipelining > defaultMaxConcurrentStreams) { + throw new InvalidArgumentError( + "h2c-client: pipelining cannot be greater than maxConcurrentStreams" + ); + } + this.#client = new Client(origin, { + ...opts, + connect: this.#buildConnector(connect2), + maxConcurrentStreams: defaultMaxConcurrentStreams, + pipelining: defaultPipelining, + allowH2: true + }); + } + #buildConnector(connectOpts) { + return (opts, callback) => { + const timeout = (connectOpts == null ? void 0 : connectOpts.connectOpts) ?? 1e4; + const { hostname, port, pathname } = opts; + const socket = connect({ + ...opts, + host: hostname, + port, + pathname + }); + if (opts.keepAlive == null || opts.keepAlive) { + const keepAliveInitialDelay = opts.keepAliveInitialDelay == null ? 6e4 : opts.keepAliveInitialDelay; + socket.setKeepAlive(true, keepAliveInitialDelay); + } + socket.alpnProtocol = "h2"; + const clearConnectTimeout = util.setupConnectTimeout( + new WeakRef(socket), + { timeout, hostname, port } + ); + socket.setNoDelay(true).once("connect", function() { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(null, this); + } + }).on("error", function(err) { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(err); + } + }); + return socket; + }; + } + dispatch(opts, handler2) { + return this.#client.dispatch(opts, handler2); + } + async [kClose]() { + await this.#client.close(); + } + async [kDestroy]() { + await this.#client.destroy(); + } + }; + module.exports = H2CClient; + } +}); + // var require_readable2 = __commonJS({ ""(exports, module) { @@ -38608,6 +38705,7 @@ var require_undici2 = __commonJS({ var ProxyAgent = require_proxy_agent2(); var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); + var H2CClient = require_h2c_client(); var errors = require_errors2(); var util = require_util8(); var { InvalidArgumentError } = errors; @@ -38631,6 +38729,7 @@ var require_undici2 = __commonJS({ module.exports.ProxyAgent = ProxyAgent; module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module.exports.RetryAgent = RetryAgent; + module.exports.H2CClient = H2CClient; module.exports.RetryHandler = RetryHandler; module.exports.DecoratorHandler = DecoratorHandler; module.exports.RedirectHandler = RedirectHandler; diff --git a/github-actions/feature-request/main.js b/github-actions/feature-request/main.js index 44422fa08..d704b6b92 100644 --- a/github-actions/feature-request/main.js +++ b/github-actions/feature-request/main.js @@ -19545,6 +19545,122 @@ var require_symbols6 = __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_errors2 = __commonJS({ ""(exports, module) { @@ -20023,7 +20139,8 @@ var require_util8 = __commonJS({ var nodeUtil = __require("node:util"); var { stringify } = __require("node:querystring"); var { EventEmitter: EE } = __require("node:events"); - var { InvalidArgumentError } = require_errors2(); + var timers = require_timers2(); + var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); var { headerNameLowerCasedRecord } = require_constants6(); var { tree } = require_tree(); var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v)); @@ -20038,6 +20155,8 @@ var require_util8 = __commonJS({ yield* this[kBody]; } }; + function noop2() { + } function wrapRequestBody(body) { if (isStream(body)) { if (bodyLength(body) === 0) { @@ -20463,6 +20582,50 @@ var require_util8 = __commonJS({ client.emit("error", err2); } } + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + let s2 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + clearImmediate(s2); + }; + } : (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) { + if (socket == null) { + return; + } + let message = "Connect Timeout Error"; + if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; + } + message += ` timeout: ${opts.timeout}ms)`; + destroy(socket, new ConnectTimeoutError(message)); + } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; var normalizedMethodRecordsBase = { @@ -20529,7 +20692,8 @@ var require_util8 = __commonJS({ nodeMajor, nodeMinor, safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]), - wrapRequestBody + wrapRequestBody, + setupConnectTimeout }; } }); @@ -21407,122 +21571,6 @@ 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) { @@ -21530,10 +21578,7 @@ var require_connect2 = __commonJS({ var net = __require("node:net"); var assert = __require("node:assert"); var util = require_util8(); - var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); - var timers = require_timers2(); - function noop2() { - } + var { InvalidArgumentError } = require_errors2(); var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21632,7 +21677,7 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); + const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { @@ -21651,50 +21696,6 @@ var require_connect2 = __commonJS({ return socket; }; } - var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { - if (!opts.timeout) { - return noop2; - } - let s1 = null; - let s2 = null; - const fastTimer = timers.setFastTimeout(() => { - s1 = setImmediate(() => { - s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); - }); - }, opts.timeout); - return () => { - timers.clearFastTimeout(fastTimer); - clearImmediate(s1); - clearImmediate(s2); - }; - } : (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) { - if (socket == null) { - return; - } - let message = "Connect Timeout Error"; - if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - 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; } }); @@ -26141,6 +26142,7 @@ var require_client_h2 = __commonJS({ } assert(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); + client.emit("connectionError", client[kUrl], [client], err); client[kResume](); } function onHttp2SessionClose() { @@ -28203,6 +28205,101 @@ var require_retry_agent = __commonJS({ } }); +// +var require_h2c_client = __commonJS({ + ""(exports, module) { + "use strict"; + var { connect } = __require("node:net"); + var { kClose, kDestroy } = require_symbols6(); + var { InvalidArgumentError } = require_errors2(); + var util = require_util8(); + var Client = require_client2(); + var DispatcherBase = require_dispatcher_base2(); + var H2CClient = class extends DispatcherBase { + #client = null; + constructor(origin, clientOpts) { + super(); + if (typeof origin === "string") { + origin = new URL(origin); + } + if (origin.protocol !== "http:") { + throw new InvalidArgumentError( + "h2c-client: Only h2c protocol is supported" + ); + } + const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {}; + let defaultMaxConcurrentStreams = 100; + let defaultPipelining = 100; + if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) { + defaultMaxConcurrentStreams = maxConcurrentStreams; + } + if (pipelining != null && Number.isInteger(pipelining) && pipelining > 0) { + defaultPipelining = pipelining; + } + if (defaultPipelining > defaultMaxConcurrentStreams) { + throw new InvalidArgumentError( + "h2c-client: pipelining cannot be greater than maxConcurrentStreams" + ); + } + this.#client = new Client(origin, { + ...opts, + connect: this.#buildConnector(connect2), + maxConcurrentStreams: defaultMaxConcurrentStreams, + pipelining: defaultPipelining, + allowH2: true + }); + } + #buildConnector(connectOpts) { + return (opts, callback) => { + const timeout = (connectOpts == null ? void 0 : connectOpts.connectOpts) ?? 1e4; + const { hostname, port, pathname } = opts; + const socket = connect({ + ...opts, + host: hostname, + port, + pathname + }); + if (opts.keepAlive == null || opts.keepAlive) { + const keepAliveInitialDelay = opts.keepAliveInitialDelay == null ? 6e4 : opts.keepAliveInitialDelay; + socket.setKeepAlive(true, keepAliveInitialDelay); + } + socket.alpnProtocol = "h2"; + const clearConnectTimeout = util.setupConnectTimeout( + new WeakRef(socket), + { timeout, hostname, port } + ); + socket.setNoDelay(true).once("connect", function() { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(null, this); + } + }).on("error", function(err) { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(err); + } + }); + return socket; + }; + } + dispatch(opts, handler2) { + return this.#client.dispatch(opts, handler2); + } + async [kClose]() { + await this.#client.close(); + } + async [kDestroy]() { + await this.#client.destroy(); + } + }; + module.exports = H2CClient; + } +}); + // var require_readable2 = __commonJS({ ""(exports, module) { @@ -38608,6 +38705,7 @@ var require_undici2 = __commonJS({ var ProxyAgent = require_proxy_agent2(); var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); + var H2CClient = require_h2c_client(); var errors = require_errors2(); var util = require_util8(); var { InvalidArgumentError } = errors; @@ -38631,6 +38729,7 @@ var require_undici2 = __commonJS({ module.exports.ProxyAgent = ProxyAgent; module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module.exports.RetryAgent = RetryAgent; + module.exports.H2CClient = H2CClient; module.exports.RetryHandler = RetryHandler; module.exports.DecoratorHandler = DecoratorHandler; module.exports.RedirectHandler = RedirectHandler; diff --git a/github-actions/google-internal-tests/main.js b/github-actions/google-internal-tests/main.js index 4ca8fdf0c..94256c82f 100644 --- a/github-actions/google-internal-tests/main.js +++ b/github-actions/google-internal-tests/main.js @@ -19549,6 +19549,122 @@ var require_symbols6 = __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_errors2 = __commonJS({ ""(exports, module) { @@ -20027,7 +20143,8 @@ var require_util8 = __commonJS({ var nodeUtil = __require("node:util"); var { stringify } = __require("node:querystring"); var { EventEmitter: EE } = __require("node:events"); - var { InvalidArgumentError } = require_errors2(); + var timers = require_timers2(); + var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); var { headerNameLowerCasedRecord } = require_constants6(); var { tree } = require_tree(); var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v)); @@ -20042,6 +20159,8 @@ var require_util8 = __commonJS({ yield* this[kBody]; } }; + function noop2() { + } function wrapRequestBody(body) { if (isStream(body)) { if (bodyLength(body) === 0) { @@ -20467,6 +20586,50 @@ var require_util8 = __commonJS({ client.emit("error", err2); } } + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + let s2 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + clearImmediate(s2); + }; + } : (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) { + if (socket == null) { + return; + } + let message = "Connect Timeout Error"; + if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; + } + message += ` timeout: ${opts.timeout}ms)`; + destroy(socket, new ConnectTimeoutError(message)); + } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; var normalizedMethodRecordsBase = { @@ -20533,7 +20696,8 @@ var require_util8 = __commonJS({ nodeMajor, nodeMinor, safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]), - wrapRequestBody + wrapRequestBody, + setupConnectTimeout }; } }); @@ -21411,122 +21575,6 @@ 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) { @@ -21534,10 +21582,7 @@ var require_connect2 = __commonJS({ var net = __require("node:net"); var assert = __require("node:assert"); var util = require_util8(); - var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); - var timers = require_timers2(); - function noop2() { - } + var { InvalidArgumentError } = require_errors2(); var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21636,7 +21681,7 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); + const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { @@ -21655,50 +21700,6 @@ var require_connect2 = __commonJS({ return socket; }; } - var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { - if (!opts.timeout) { - return noop2; - } - let s1 = null; - let s2 = null; - const fastTimer = timers.setFastTimeout(() => { - s1 = setImmediate(() => { - s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); - }); - }, opts.timeout); - return () => { - timers.clearFastTimeout(fastTimer); - clearImmediate(s1); - clearImmediate(s2); - }; - } : (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) { - if (socket == null) { - return; - } - let message = "Connect Timeout Error"; - if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - 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; } }); @@ -26145,6 +26146,7 @@ var require_client_h2 = __commonJS({ } assert(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); + client.emit("connectionError", client[kUrl], [client], err); client[kResume](); } function onHttp2SessionClose() { @@ -28207,6 +28209,101 @@ var require_retry_agent = __commonJS({ } }); +// +var require_h2c_client = __commonJS({ + ""(exports, module) { + "use strict"; + var { connect } = __require("node:net"); + var { kClose, kDestroy } = require_symbols6(); + var { InvalidArgumentError } = require_errors2(); + var util = require_util8(); + var Client = require_client2(); + var DispatcherBase = require_dispatcher_base2(); + var H2CClient = class extends DispatcherBase { + #client = null; + constructor(origin, clientOpts) { + super(); + if (typeof origin === "string") { + origin = new URL(origin); + } + if (origin.protocol !== "http:") { + throw new InvalidArgumentError( + "h2c-client: Only h2c protocol is supported" + ); + } + const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {}; + let defaultMaxConcurrentStreams = 100; + let defaultPipelining = 100; + if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) { + defaultMaxConcurrentStreams = maxConcurrentStreams; + } + if (pipelining != null && Number.isInteger(pipelining) && pipelining > 0) { + defaultPipelining = pipelining; + } + if (defaultPipelining > defaultMaxConcurrentStreams) { + throw new InvalidArgumentError( + "h2c-client: pipelining cannot be greater than maxConcurrentStreams" + ); + } + this.#client = new Client(origin, { + ...opts, + connect: this.#buildConnector(connect2), + maxConcurrentStreams: defaultMaxConcurrentStreams, + pipelining: defaultPipelining, + allowH2: true + }); + } + #buildConnector(connectOpts) { + return (opts, callback) => { + const timeout = (connectOpts == null ? void 0 : connectOpts.connectOpts) ?? 1e4; + const { hostname, port, pathname } = opts; + const socket = connect({ + ...opts, + host: hostname, + port, + pathname + }); + if (opts.keepAlive == null || opts.keepAlive) { + const keepAliveInitialDelay = opts.keepAliveInitialDelay == null ? 6e4 : opts.keepAliveInitialDelay; + socket.setKeepAlive(true, keepAliveInitialDelay); + } + socket.alpnProtocol = "h2"; + const clearConnectTimeout = util.setupConnectTimeout( + new WeakRef(socket), + { timeout, hostname, port } + ); + socket.setNoDelay(true).once("connect", function() { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(null, this); + } + }).on("error", function(err) { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(err); + } + }); + return socket; + }; + } + dispatch(opts, handler2) { + return this.#client.dispatch(opts, handler2); + } + async [kClose]() { + await this.#client.close(); + } + async [kDestroy]() { + await this.#client.destroy(); + } + }; + module.exports = H2CClient; + } +}); + // var require_readable2 = __commonJS({ ""(exports, module) { @@ -38612,6 +38709,7 @@ var require_undici2 = __commonJS({ var ProxyAgent = require_proxy_agent2(); var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); + var H2CClient = require_h2c_client(); var errors = require_errors2(); var util = require_util8(); var { InvalidArgumentError } = errors; @@ -38635,6 +38733,7 @@ var require_undici2 = __commonJS({ module.exports.ProxyAgent = ProxyAgent; module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module.exports.RetryAgent = RetryAgent; + module.exports.H2CClient = H2CClient; module.exports.RetryHandler = RetryHandler; module.exports.DecoratorHandler = DecoratorHandler; module.exports.RedirectHandler = RedirectHandler; diff --git a/github-actions/org-file-sync/main.js b/github-actions/org-file-sync/main.js index d4a2bcb3e..fcc9d84a2 100644 --- a/github-actions/org-file-sync/main.js +++ b/github-actions/org-file-sync/main.js @@ -19545,6 +19545,122 @@ var require_symbols6 = __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_errors2 = __commonJS({ ""(exports, module) { @@ -20023,7 +20139,8 @@ var require_util8 = __commonJS({ var nodeUtil = __require("node:util"); var { stringify } = __require("node:querystring"); var { EventEmitter: EE } = __require("node:events"); - var { InvalidArgumentError } = require_errors2(); + var timers = require_timers2(); + var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); var { headerNameLowerCasedRecord } = require_constants6(); var { tree } = require_tree(); var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v)); @@ -20038,6 +20155,8 @@ var require_util8 = __commonJS({ yield* this[kBody]; } }; + function noop2() { + } function wrapRequestBody(body) { if (isStream(body)) { if (bodyLength(body) === 0) { @@ -20463,6 +20582,50 @@ var require_util8 = __commonJS({ client.emit("error", err2); } } + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + let s2 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + clearImmediate(s2); + }; + } : (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) { + if (socket == null) { + return; + } + let message = "Connect Timeout Error"; + if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; + } + message += ` timeout: ${opts.timeout}ms)`; + destroy(socket, new ConnectTimeoutError(message)); + } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; var normalizedMethodRecordsBase = { @@ -20529,7 +20692,8 @@ var require_util8 = __commonJS({ nodeMajor, nodeMinor, safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]), - wrapRequestBody + wrapRequestBody, + setupConnectTimeout }; } }); @@ -21407,122 +21571,6 @@ 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) { @@ -21530,10 +21578,7 @@ var require_connect2 = __commonJS({ var net = __require("node:net"); var assert = __require("node:assert"); var util = require_util8(); - var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); - var timers = require_timers2(); - function noop2() { - } + var { InvalidArgumentError } = require_errors2(); var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21632,7 +21677,7 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); + const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { @@ -21651,50 +21696,6 @@ var require_connect2 = __commonJS({ return socket; }; } - var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { - if (!opts.timeout) { - return noop2; - } - let s1 = null; - let s2 = null; - const fastTimer = timers.setFastTimeout(() => { - s1 = setImmediate(() => { - s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); - }); - }, opts.timeout); - return () => { - timers.clearFastTimeout(fastTimer); - clearImmediate(s1); - clearImmediate(s2); - }; - } : (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) { - if (socket == null) { - return; - } - let message = "Connect Timeout Error"; - if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - 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; } }); @@ -26141,6 +26142,7 @@ var require_client_h2 = __commonJS({ } assert(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); + client.emit("connectionError", client[kUrl], [client], err); client[kResume](); } function onHttp2SessionClose() { @@ -28203,6 +28205,101 @@ var require_retry_agent = __commonJS({ } }); +// +var require_h2c_client = __commonJS({ + ""(exports, module) { + "use strict"; + var { connect } = __require("node:net"); + var { kClose, kDestroy } = require_symbols6(); + var { InvalidArgumentError } = require_errors2(); + var util = require_util8(); + var Client = require_client2(); + var DispatcherBase = require_dispatcher_base2(); + var H2CClient = class extends DispatcherBase { + #client = null; + constructor(origin, clientOpts) { + super(); + if (typeof origin === "string") { + origin = new URL(origin); + } + if (origin.protocol !== "http:") { + throw new InvalidArgumentError( + "h2c-client: Only h2c protocol is supported" + ); + } + const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {}; + let defaultMaxConcurrentStreams = 100; + let defaultPipelining = 100; + if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) { + defaultMaxConcurrentStreams = maxConcurrentStreams; + } + if (pipelining != null && Number.isInteger(pipelining) && pipelining > 0) { + defaultPipelining = pipelining; + } + if (defaultPipelining > defaultMaxConcurrentStreams) { + throw new InvalidArgumentError( + "h2c-client: pipelining cannot be greater than maxConcurrentStreams" + ); + } + this.#client = new Client(origin, { + ...opts, + connect: this.#buildConnector(connect2), + maxConcurrentStreams: defaultMaxConcurrentStreams, + pipelining: defaultPipelining, + allowH2: true + }); + } + #buildConnector(connectOpts) { + return (opts, callback) => { + const timeout = (connectOpts == null ? void 0 : connectOpts.connectOpts) ?? 1e4; + const { hostname, port, pathname } = opts; + const socket = connect({ + ...opts, + host: hostname, + port, + pathname + }); + if (opts.keepAlive == null || opts.keepAlive) { + const keepAliveInitialDelay = opts.keepAliveInitialDelay == null ? 6e4 : opts.keepAliveInitialDelay; + socket.setKeepAlive(true, keepAliveInitialDelay); + } + socket.alpnProtocol = "h2"; + const clearConnectTimeout = util.setupConnectTimeout( + new WeakRef(socket), + { timeout, hostname, port } + ); + socket.setNoDelay(true).once("connect", function() { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(null, this); + } + }).on("error", function(err) { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(err); + } + }); + return socket; + }; + } + dispatch(opts, handler2) { + return this.#client.dispatch(opts, handler2); + } + async [kClose]() { + await this.#client.close(); + } + async [kDestroy]() { + await this.#client.destroy(); + } + }; + module.exports = H2CClient; + } +}); + // var require_readable2 = __commonJS({ ""(exports, module) { @@ -38608,6 +38705,7 @@ var require_undici2 = __commonJS({ var ProxyAgent = require_proxy_agent2(); var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); + var H2CClient = require_h2c_client(); var errors = require_errors2(); var util = require_util8(); var { InvalidArgumentError } = errors; @@ -38631,6 +38729,7 @@ var require_undici2 = __commonJS({ module.exports.ProxyAgent = ProxyAgent; module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module.exports.RetryAgent = RetryAgent; + module.exports.H2CClient = H2CClient; module.exports.RetryHandler = RetryHandler; module.exports.DecoratorHandler = DecoratorHandler; module.exports.RedirectHandler = RedirectHandler; diff --git a/github-actions/post-approval-changes/main.js b/github-actions/post-approval-changes/main.js index e1b5d5672..dbf745ec2 100644 --- a/github-actions/post-approval-changes/main.js +++ b/github-actions/post-approval-changes/main.js @@ -19545,6 +19545,122 @@ var require_symbols6 = __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_errors2 = __commonJS({ ""(exports, module) { @@ -20023,7 +20139,8 @@ var require_util8 = __commonJS({ var nodeUtil = __require("node:util"); var { stringify } = __require("node:querystring"); var { EventEmitter: EE } = __require("node:events"); - var { InvalidArgumentError } = require_errors2(); + var timers = require_timers2(); + var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); var { headerNameLowerCasedRecord } = require_constants6(); var { tree } = require_tree(); var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v)); @@ -20038,6 +20155,8 @@ var require_util8 = __commonJS({ yield* this[kBody]; } }; + function noop2() { + } function wrapRequestBody(body) { if (isStream(body)) { if (bodyLength(body) === 0) { @@ -20463,6 +20582,50 @@ var require_util8 = __commonJS({ client.emit("error", err2); } } + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + let s2 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + clearImmediate(s2); + }; + } : (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) { + if (socket == null) { + return; + } + let message = "Connect Timeout Error"; + if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; + } + message += ` timeout: ${opts.timeout}ms)`; + destroy(socket, new ConnectTimeoutError(message)); + } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; var normalizedMethodRecordsBase = { @@ -20529,7 +20692,8 @@ var require_util8 = __commonJS({ nodeMajor, nodeMinor, safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]), - wrapRequestBody + wrapRequestBody, + setupConnectTimeout }; } }); @@ -21407,122 +21571,6 @@ 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) { @@ -21530,10 +21578,7 @@ var require_connect2 = __commonJS({ var net = __require("node:net"); var assert = __require("node:assert"); var util = require_util8(); - var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); - var timers = require_timers2(); - function noop2() { - } + var { InvalidArgumentError } = require_errors2(); var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21632,7 +21677,7 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); + const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { @@ -21651,50 +21696,6 @@ var require_connect2 = __commonJS({ return socket; }; } - var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { - if (!opts.timeout) { - return noop2; - } - let s1 = null; - let s2 = null; - const fastTimer = timers.setFastTimeout(() => { - s1 = setImmediate(() => { - s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); - }); - }, opts.timeout); - return () => { - timers.clearFastTimeout(fastTimer); - clearImmediate(s1); - clearImmediate(s2); - }; - } : (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) { - if (socket == null) { - return; - } - let message = "Connect Timeout Error"; - if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - 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; } }); @@ -26141,6 +26142,7 @@ var require_client_h2 = __commonJS({ } assert(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); + client.emit("connectionError", client[kUrl], [client], err); client[kResume](); } function onHttp2SessionClose() { @@ -28203,6 +28205,101 @@ var require_retry_agent = __commonJS({ } }); +// +var require_h2c_client = __commonJS({ + ""(exports, module) { + "use strict"; + var { connect } = __require("node:net"); + var { kClose, kDestroy } = require_symbols6(); + var { InvalidArgumentError } = require_errors2(); + var util = require_util8(); + var Client = require_client2(); + var DispatcherBase = require_dispatcher_base2(); + var H2CClient = class extends DispatcherBase { + #client = null; + constructor(origin, clientOpts) { + super(); + if (typeof origin === "string") { + origin = new URL(origin); + } + if (origin.protocol !== "http:") { + throw new InvalidArgumentError( + "h2c-client: Only h2c protocol is supported" + ); + } + const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {}; + let defaultMaxConcurrentStreams = 100; + let defaultPipelining = 100; + if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) { + defaultMaxConcurrentStreams = maxConcurrentStreams; + } + if (pipelining != null && Number.isInteger(pipelining) && pipelining > 0) { + defaultPipelining = pipelining; + } + if (defaultPipelining > defaultMaxConcurrentStreams) { + throw new InvalidArgumentError( + "h2c-client: pipelining cannot be greater than maxConcurrentStreams" + ); + } + this.#client = new Client(origin, { + ...opts, + connect: this.#buildConnector(connect2), + maxConcurrentStreams: defaultMaxConcurrentStreams, + pipelining: defaultPipelining, + allowH2: true + }); + } + #buildConnector(connectOpts) { + return (opts, callback) => { + const timeout = (connectOpts == null ? void 0 : connectOpts.connectOpts) ?? 1e4; + const { hostname, port, pathname } = opts; + const socket = connect({ + ...opts, + host: hostname, + port, + pathname + }); + if (opts.keepAlive == null || opts.keepAlive) { + const keepAliveInitialDelay = opts.keepAliveInitialDelay == null ? 6e4 : opts.keepAliveInitialDelay; + socket.setKeepAlive(true, keepAliveInitialDelay); + } + socket.alpnProtocol = "h2"; + const clearConnectTimeout = util.setupConnectTimeout( + new WeakRef(socket), + { timeout, hostname, port } + ); + socket.setNoDelay(true).once("connect", function() { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(null, this); + } + }).on("error", function(err) { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(err); + } + }); + return socket; + }; + } + dispatch(opts, handler2) { + return this.#client.dispatch(opts, handler2); + } + async [kClose]() { + await this.#client.close(); + } + async [kDestroy]() { + await this.#client.destroy(); + } + }; + module.exports = H2CClient; + } +}); + // var require_readable2 = __commonJS({ ""(exports, module) { @@ -38608,6 +38705,7 @@ var require_undici2 = __commonJS({ var ProxyAgent = require_proxy_agent2(); var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); + var H2CClient = require_h2c_client(); var errors = require_errors2(); var util = require_util8(); var { InvalidArgumentError } = errors; @@ -38631,6 +38729,7 @@ var require_undici2 = __commonJS({ module.exports.ProxyAgent = ProxyAgent; module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module.exports.RetryAgent = RetryAgent; + module.exports.H2CClient = H2CClient; module.exports.RetryHandler = RetryHandler; module.exports.DecoratorHandler = DecoratorHandler; module.exports.RedirectHandler = RedirectHandler; diff --git a/github-actions/unified-status-check/main.js b/github-actions/unified-status-check/main.js index 4ffca6b2e..bd0cd5987 100644 --- a/github-actions/unified-status-check/main.js +++ b/github-actions/unified-status-check/main.js @@ -19641,6 +19641,122 @@ var require_symbols6 = __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_errors2 = __commonJS({ ""(exports, module) { @@ -20119,7 +20235,8 @@ var require_util8 = __commonJS({ var nodeUtil = __require("node:util"); var { stringify } = __require("node:querystring"); var { EventEmitter: EE } = __require("node:events"); - var { InvalidArgumentError } = require_errors2(); + var timers = require_timers2(); + var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); var { headerNameLowerCasedRecord } = require_constants6(); var { tree } = require_tree(); var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v)); @@ -20134,6 +20251,8 @@ var require_util8 = __commonJS({ yield* this[kBody]; } }; + function noop2() { + } function wrapRequestBody(body) { if (isStream(body)) { if (bodyLength(body) === 0) { @@ -20559,6 +20678,50 @@ var require_util8 = __commonJS({ client.emit("error", err2); } } + var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { + if (!opts.timeout) { + return noop2; + } + let s1 = null; + let s2 = null; + const fastTimer = timers.setFastTimeout(() => { + s1 = setImmediate(() => { + s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); + }); + }, opts.timeout); + return () => { + timers.clearFastTimeout(fastTimer); + clearImmediate(s1); + clearImmediate(s2); + }; + } : (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) { + if (socket == null) { + return; + } + let message = "Connect Timeout Error"; + if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { + message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`; + } else { + message += ` (attempted address: ${opts.hostname}:${opts.port},`; + } + message += ` timeout: ${opts.timeout}ms)`; + destroy(socket, new ConnectTimeoutError(message)); + } var kEnumerableProperty = /* @__PURE__ */ Object.create(null); kEnumerableProperty.enumerable = true; var normalizedMethodRecordsBase = { @@ -20625,7 +20788,8 @@ var require_util8 = __commonJS({ nodeMajor, nodeMinor, safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]), - wrapRequestBody + wrapRequestBody, + setupConnectTimeout }; } }); @@ -21503,122 +21667,6 @@ 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) { @@ -21626,10 +21674,7 @@ var require_connect2 = __commonJS({ var net = __require("node:net"); var assert = __require("node:assert"); var util = require_util8(); - var { InvalidArgumentError, ConnectTimeoutError } = require_errors2(); - var timers = require_timers2(); - function noop2() { - } + var { InvalidArgumentError } = require_errors2(); var tls; var SessionCache; if (global.FinalizationRegistry && !(process.env.NODE_V8_COVERAGE || process.env.UNDICI_NO_FG)) { @@ -21728,7 +21773,7 @@ var require_connect2 = __commonJS({ const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay; socket.setKeepAlive(true, keepAliveInitialDelay); } - const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); + const clearConnectTimeout = util.setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port }); socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() { queueMicrotask(clearConnectTimeout); if (callback) { @@ -21747,50 +21792,6 @@ var require_connect2 = __commonJS({ return socket; }; } - var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => { - if (!opts.timeout) { - return noop2; - } - let s1 = null; - let s2 = null; - const fastTimer = timers.setFastTimeout(() => { - s1 = setImmediate(() => { - s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts)); - }); - }, opts.timeout); - return () => { - timers.clearFastTimeout(fastTimer); - clearImmediate(s1); - clearImmediate(s2); - }; - } : (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) { - if (socket == null) { - return; - } - let message = "Connect Timeout Error"; - if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) { - 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; } }); @@ -26237,6 +26238,7 @@ var require_client_h2 = __commonJS({ } assert(client[kRunning] === 0); client.emit("disconnect", client[kUrl], [client], err); + client.emit("connectionError", client[kUrl], [client], err); client[kResume](); } function onHttp2SessionClose() { @@ -28299,6 +28301,101 @@ var require_retry_agent = __commonJS({ } }); +// +var require_h2c_client = __commonJS({ + ""(exports, module) { + "use strict"; + var { connect } = __require("node:net"); + var { kClose, kDestroy } = require_symbols6(); + var { InvalidArgumentError } = require_errors2(); + var util = require_util8(); + var Client = require_client2(); + var DispatcherBase = require_dispatcher_base2(); + var H2CClient = class extends DispatcherBase { + #client = null; + constructor(origin, clientOpts) { + super(); + if (typeof origin === "string") { + origin = new URL(origin); + } + if (origin.protocol !== "http:") { + throw new InvalidArgumentError( + "h2c-client: Only h2c protocol is supported" + ); + } + const { connect: connect2, maxConcurrentStreams, pipelining, ...opts } = clientOpts ?? {}; + let defaultMaxConcurrentStreams = 100; + let defaultPipelining = 100; + if (maxConcurrentStreams != null && Number.isInteger(maxConcurrentStreams) && maxConcurrentStreams > 0) { + defaultMaxConcurrentStreams = maxConcurrentStreams; + } + if (pipelining != null && Number.isInteger(pipelining) && pipelining > 0) { + defaultPipelining = pipelining; + } + if (defaultPipelining > defaultMaxConcurrentStreams) { + throw new InvalidArgumentError( + "h2c-client: pipelining cannot be greater than maxConcurrentStreams" + ); + } + this.#client = new Client(origin, { + ...opts, + connect: this.#buildConnector(connect2), + maxConcurrentStreams: defaultMaxConcurrentStreams, + pipelining: defaultPipelining, + allowH2: true + }); + } + #buildConnector(connectOpts) { + return (opts, callback) => { + const timeout = (connectOpts == null ? void 0 : connectOpts.connectOpts) ?? 1e4; + const { hostname, port, pathname } = opts; + const socket = connect({ + ...opts, + host: hostname, + port, + pathname + }); + if (opts.keepAlive == null || opts.keepAlive) { + const keepAliveInitialDelay = opts.keepAliveInitialDelay == null ? 6e4 : opts.keepAliveInitialDelay; + socket.setKeepAlive(true, keepAliveInitialDelay); + } + socket.alpnProtocol = "h2"; + const clearConnectTimeout = util.setupConnectTimeout( + new WeakRef(socket), + { timeout, hostname, port } + ); + socket.setNoDelay(true).once("connect", function() { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(null, this); + } + }).on("error", function(err) { + queueMicrotask(clearConnectTimeout); + if (callback) { + const cb = callback; + callback = null; + cb(err); + } + }); + return socket; + }; + } + dispatch(opts, handler2) { + return this.#client.dispatch(opts, handler2); + } + async [kClose]() { + await this.#client.close(); + } + async [kDestroy]() { + await this.#client.destroy(); + } + }; + module.exports = H2CClient; + } +}); + // var require_readable2 = __commonJS({ ""(exports, module) { @@ -38704,6 +38801,7 @@ var require_undici2 = __commonJS({ var ProxyAgent = require_proxy_agent2(); var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); + var H2CClient = require_h2c_client(); var errors = require_errors2(); var util = require_util8(); var { InvalidArgumentError } = errors; @@ -38727,6 +38825,7 @@ var require_undici2 = __commonJS({ module.exports.ProxyAgent = ProxyAgent; module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module.exports.RetryAgent = RetryAgent; + module.exports.H2CClient = H2CClient; module.exports.RetryHandler = RetryHandler; module.exports.DecoratorHandler = DecoratorHandler; module.exports.RedirectHandler = RedirectHandler; diff --git a/yarn.lock b/yarn.lock index bbb0dcc51..6231a89b6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5509,20 +5509,20 @@ __metadata: languageName: node linkType: hard -"browser-sync-client@npm:^3.0.3": - version: 3.0.3 - resolution: "browser-sync-client@npm:3.0.3" +"browser-sync-client@npm:^3.0.4": + version: 3.0.4 + resolution: "browser-sync-client@npm:3.0.4" dependencies: etag: "npm:1.8.1" fresh: "npm:0.5.2" mitt: "npm:^1.1.3" - checksum: 10c0/76b8a2881e01371a0d7e71ac7e67d8add74b264857f13a510ac7219cbeb9092fb1d06d65738a696b576eff92aaefb9707c75d3373559542b6993d97002187705 + checksum: 10c0/3be35b9d03855537468754580502a8911d142978d82bce9b71a5e9f989703e72876fc6b824a7b44e141a32e8734de7e4a18bc963767a8933e84603f890066e3a languageName: node linkType: hard -"browser-sync-ui@npm:^3.0.3": - version: 3.0.3 - resolution: "browser-sync-ui@npm:3.0.3" +"browser-sync-ui@npm:^3.0.4": + version: 3.0.4 + resolution: "browser-sync-ui@npm:3.0.4" dependencies: async-each-series: "npm:0.1.1" chalk: "npm:4.1.2" @@ -5531,16 +5531,16 @@ __metadata: server-destroy: "npm:1.0.1" socket.io-client: "npm:^4.4.1" stream-throttle: "npm:^0.1.3" - checksum: 10c0/b755e58efa9fc9ada0ac955a9d562ea0e069db98c223d432db3c51b2668b28338e0116469c51be93f6d00ef3eaa4a27a24f684a52d4bf9527a56fdf1bb7b057b + checksum: 10c0/b3d8ffa8b027c1628c90a11b3778f9c5d60b9078b3967a1b172d6fbb8f7b42385815b4073509e9f67f57b611eb4e1409baeae2783bdfaf077e56ae22d0b6dbe2 languageName: node linkType: hard "browser-sync@npm:^3.0.0": - version: 3.0.3 - resolution: "browser-sync@npm:3.0.3" + version: 3.0.4 + resolution: "browser-sync@npm:3.0.4" dependencies: - browser-sync-client: "npm:^3.0.3" - browser-sync-ui: "npm:^3.0.3" + browser-sync-client: "npm:^3.0.4" + browser-sync-ui: "npm:^3.0.4" bs-recipes: "npm:1.3.4" chalk: "npm:4.1.2" chokidar: "npm:^3.5.1" @@ -5548,7 +5548,7 @@ __metadata: connect-history-api-fallback: "npm:^1" dev-ip: "npm:^1.0.1" easy-extender: "npm:^2.3.4" - eazy-logger: "npm:^4.0.1" + eazy-logger: "npm:^4.1.0" etag: "npm:^1.8.1" fresh: "npm:^0.5.2" fs-extra: "npm:3.0.1" @@ -5569,7 +5569,7 @@ __metadata: yargs: "npm:^17.3.1" bin: browser-sync: dist/bin.js - checksum: 10c0/96ac1399751fa256719862e428e8073b48233cc6c0bccb8faae7b51e3da8111f13b3b91fd5a090b3f746125887c4708f48313ef5b65d29235c5a786045e11608 + checksum: 10c0/c9d709f188f8a2736f3e3ee02830b5e2d86e5ba539d1cb494a6fbe86a8d89cf01cdc96a2ac437bafaeed2ca4ed07e906f7f39191c5ab66c8e2a8ad39d172b133 languageName: node linkType: hard @@ -6892,12 +6892,12 @@ __metadata: languageName: node linkType: hard -"eazy-logger@npm:^4.0.1": - version: 4.0.1 - resolution: "eazy-logger@npm:4.0.1" +"eazy-logger@npm:^4.1.0": + version: 4.1.0 + resolution: "eazy-logger@npm:4.1.0" dependencies: chalk: "npm:4.1.2" - checksum: 10c0/e562265e7c49bd5a4535c66a61749b22e55b4978c48223f0f5b84ed1c5b59397510d655e24b764c0f4b0209f45c7e70a02cb00eaa748d5f44f6d58a4caaac971 + checksum: 10c0/9e14bdc3a504636c26250da88160e6318a798a1a5c3445f8af3b5f1e9775d559c774c2e447c72d880401ef31989875ee9a486d8a7c1fdf9404b534b5f95afa7a languageName: node linkType: hard @@ -14529,9 +14529,9 @@ __metadata: linkType: hard "undici@npm:^7.0.0": - version: 7.6.0 - resolution: "undici@npm:7.6.0" - checksum: 10c0/53824a217c47dfc00961b8f504ebfa30f469357f2e5444320cbe446774dd4a836c37317a5d4ddf1ac61ab936ef05e081cc6a32ec60ac9e65dea841468397430d + version: 7.7.0 + resolution: "undici@npm:7.7.0" + checksum: 10c0/2e535e56b5d462337e0dc57012659dab016a2596bc23dd44637c2b81b6947eb236c3390ccc9293f399032d363474f66cf836bc5ee14889fbcf820fa42181c629 languageName: node linkType: hard