@@ -41481,7 +41481,6 @@ var require_client_h2 = __commonJS({
4148141481 } = require_symbols6();
4148241482 var kOpenStreams = Symbol("open streams");
4148341483 var extractBody;
41484- var h2ExperimentalWarned = false;
4148541484 var http2;
4148641485 try {
4148741486 http2 = __require("node:http2");
@@ -41514,12 +41513,6 @@ var require_client_h2 = __commonJS({
4151441513 }
4151541514 async function connectH2(client, socket) {
4151641515 client[kSocket] = socket;
41517- if (!h2ExperimentalWarned) {
41518- h2ExperimentalWarned = true;
41519- process.emitWarning("H2 support is experimental, expect them to change at any time.", {
41520- code: "UNDICI-H2"
41521- });
41522- }
4152341516 const session = http2.connect(client[kUrl], {
4152441517 createConnection: () => socket,
4152541518 peerMaxConcurrentStreams: client[kMaxConcurrentStreams],
@@ -45565,61 +45558,55 @@ var require_decorator_handler = __commonJS({
4556545558 ""(exports, module) {
4556645559 "use strict";
4556745560 var assert2 = __require("node:assert");
45561+ var WrapHandler = require_wrap_handler();
4556845562 module.exports = class DecoratorHandler {
4556945563 #handler;
4557045564 #onCompleteCalled = false;
4557145565 #onErrorCalled = false;
45566+ #onResponseStartCalled = false;
4557245567 constructor(handler2) {
4557345568 if (typeof handler2 !== "object" || handler2 === null) {
4557445569 throw new TypeError("handler must be an object");
4557545570 }
45576- this.#handler = handler2;
45577- }
45578- onConnect(...args) {
45579- var _a, _b;
45580- return (_b = (_a = this.#handler).onConnect) == null ? void 0 : _b.call(_a, ...args);
45581- }
45582- onError(...args) {
45583- var _a, _b;
45584- this.#onErrorCalled = true;
45585- return (_b = (_a = this.#handler).onError) == null ? void 0 : _b.call(_a, ...args);
45571+ this.#handler = WrapHandler.wrap(handler2);
4558645572 }
45587- onUpgrade (...args) {
45573+ onRequestStart (...args) {
4558845574 var _a, _b;
45589- assert2(!this.#onCompleteCalled);
45590- assert2(!this.#onErrorCalled);
45591- return (_b = (_a = this.#handler).onUpgrade) == null ? void 0 : _b.call(_a, ...args);
45575+ (_b = (_a = this.#handler).onRequestStart) == null ? void 0 : _b.call(_a, ...args);
4559245576 }
45593- onResponseStarted (...args) {
45577+ onRequestUpgrade (...args) {
4559445578 var _a, _b;
4559545579 assert2(!this.#onCompleteCalled);
4559645580 assert2(!this.#onErrorCalled);
45597- return (_b = (_a = this.#handler).onResponseStarted ) == null ? void 0 : _b.call(_a, ...args);
45581+ return (_b = (_a = this.#handler).onRequestUpgrade ) == null ? void 0 : _b.call(_a, ...args);
4559845582 }
45599- onHeaders (...args) {
45583+ onResponseStart (...args) {
4560045584 var _a, _b;
4560145585 assert2(!this.#onCompleteCalled);
4560245586 assert2(!this.#onErrorCalled);
45603- return (_b = (_a = this.#handler).onHeaders) == null ? void 0 : _b.call(_a, ...args);
45587+ assert2(!this.#onResponseStartCalled);
45588+ this.#onResponseStartCalled = true;
45589+ return (_b = (_a = this.#handler).onResponseStart) == null ? void 0 : _b.call(_a, ...args);
4560445590 }
45605- onData (...args) {
45591+ onResponseData (...args) {
4560645592 var _a, _b;
4560745593 assert2(!this.#onCompleteCalled);
4560845594 assert2(!this.#onErrorCalled);
45609- return (_b = (_a = this.#handler).onData ) == null ? void 0 : _b.call(_a, ...args);
45595+ return (_b = (_a = this.#handler).onResponseData ) == null ? void 0 : _b.call(_a, ...args);
4561045596 }
45611- onComplete (...args) {
45597+ onResponseEnd (...args) {
4561245598 var _a, _b;
4561345599 assert2(!this.#onCompleteCalled);
4561445600 assert2(!this.#onErrorCalled);
4561545601 this.#onCompleteCalled = true;
45616- return (_b = (_a = this.#handler).onComplete ) == null ? void 0 : _b.call(_a, ...args);
45602+ return (_b = (_a = this.#handler).onResponseEnd ) == null ? void 0 : _b.call(_a, ...args);
4561745603 }
45618- onBodySent (...args) {
45604+ onResponseError (...args) {
4561945605 var _a, _b;
45620- assert2(!this.#onCompleteCalled);
45621- assert2(!this.#onErrorCalled);
45622- return (_b = (_a = this.#handler).onBodySent) == null ? void 0 : _b.call(_a, ...args);
45606+ this.#onErrorCalled = true;
45607+ return (_b = (_a = this.#handler).onResponseError) == null ? void 0 : _b.call(_a, ...args);
45608+ }
45609+ onBodySent() {
4562345610 }
4562445611 };
4562545612 }
@@ -45810,50 +45797,47 @@ var require_redirect = __commonJS({
4581045797var require_response_error = __commonJS({
4581145798 ""(exports, module) {
4581245799 "use strict";
45813- var { parseHeaders } = require_util8();
4581445800 var DecoratorHandler = require_decorator_handler();
4581545801 var { ResponseError } = require_errors2();
4581645802 var ResponseErrorHandler = class extends DecoratorHandler {
45817- #handler;
4581845803 #statusCode;
4581945804 #contentType;
4582045805 #decoder;
4582145806 #headers;
4582245807 #body;
45823- constructor(opts , { handler: handler2 }) {
45808+ constructor(_opts , { handler: handler2 }) {
4582445809 super(handler2);
45825- this.#handler = handler2;
4582645810 }
45827- onConnect(abort) {
45811+ #checkContentType(contentType) {
45812+ return this.#contentType.indexOf(contentType) === 0;
45813+ }
45814+ onRequestStart(controller, context2) {
4582845815 this.#statusCode = 0;
4582945816 this.#contentType = null;
4583045817 this.#decoder = null;
4583145818 this.#headers = null;
4583245819 this.#body = "";
45833- return this.#handler.onConnect(abort );
45820+ return super.onRequestStart(controller, context2 );
4583445821 }
45835- #checkContentType(contentType) {
45836- return this.#contentType.indexOf(contentType) === 0;
45837- }
45838- onHeaders(statusCode, rawHeaders, resume, statusMessage, headers = parseHeaders(rawHeaders)) {
45822+ onResponseStart(controller, statusCode, headers, statusMessage) {
4583945823 this.#statusCode = statusCode;
4584045824 this.#headers = headers;
4584145825 this.#contentType = headers["content-type"];
4584245826 if (this.#statusCode < 400) {
45843- return this.#handler.onHeaders(statusCode, rawHeaders, resume , statusMessage, headers );
45827+ return super.onResponseStart(controller, statusCode, headers , statusMessage);
4584445828 }
4584545829 if (this.#checkContentType("application/json") || this.#checkContentType("text/plain")) {
4584645830 this.#decoder = new TextDecoder("utf-8");
4584745831 }
4584845832 }
45849- onData( chunk) {
45833+ onResponseData(controller, chunk) {
4585045834 var _a;
4585145835 if (this.#statusCode < 400) {
45852- return this.#handler.onData( chunk);
45836+ return super.onResponseData(controller, chunk);
4585345837 }
4585445838 this.#body += ((_a = this.#decoder) == null ? void 0 : _a.decode(chunk, { stream: true })) ?? "";
4585545839 }
45856- onComplete(rawTrailers ) {
45840+ onResponseEnd(controller, trailers ) {
4585745841 var _a;
4585845842 if (this.#statusCode >= 400) {
4585945843 this.#body += ((_a = this.#decoder) == null ? void 0 : _a.decode(void 0, { stream: false })) ?? "";
@@ -45874,13 +45858,13 @@ var require_response_error = __commonJS({
4587445858 } finally {
4587545859 Error.stackTraceLimit = stackTraceLimit;
4587645860 }
45877- this.#handler.onError( err);
45861+ super.onResponseError(controller, err);
4587845862 } else {
45879- this.#handler.onComplete(rawTrailers );
45863+ super.onResponseEnd(controller, trailers );
4588045864 }
4588145865 }
45882- onError (err) {
45883- this.#handler.onError (err);
45866+ onResponseError (err) {
45867+ super.onResponseError (err);
4588445868 }
4588545869 };
4588645870 module.exports = () => {
@@ -45921,79 +45905,71 @@ var require_retry = __commonJS({
4592145905var require_dump = __commonJS({
4592245906 ""(exports, module) {
4592345907 "use strict";
45924- var util = require_util8();
4592545908 var { InvalidArgumentError, RequestAbortedError } = require_errors2();
4592645909 var DecoratorHandler = require_decorator_handler();
4592745910 var DumpHandler = class extends DecoratorHandler {
4592845911 #maxSize = 1024 * 1024;
45929- #abort = null;
4593045912 #dumped = false;
45931- #aborted = false;
4593245913 #size = 0;
45933- #reason = null;
45934- #handler = null;
45935- constructor({ maxSize }, handler2) {
45914+ #controller = null;
45915+ aborted = false;
45916+ reason = false;
45917+ constructor({ maxSize, signal }, handler2) {
4593645918 if (maxSize != null && (!Number.isFinite(maxSize) || maxSize < 1)) {
4593745919 throw new InvalidArgumentError("maxSize must be a number greater than 0");
4593845920 }
4593945921 super(handler2);
4594045922 this.#maxSize = maxSize ?? this.#maxSize;
45941- this.#handler = handler2;
4594245923 }
45943- onConnect( abort) {
45944- this.#abort = abort ;
45945- this.#handler.onConnect(this.#customAbort.bind(this)) ;
45924+ # abort(reason ) {
45925+ this.aborted = true ;
45926+ this.reason = reason ;
4594645927 }
45947- #customAbort(reason) {
45948- this.#aborted = true;
45949- this.#reason = reason;
45928+ onRequestStart(controller, context2) {
45929+ controller.abort = this.#abort.bind(this);
45930+ this.#controller = controller;
45931+ return super.onRequestStart(controller, context2);
4595045932 }
45951- onHeaders(statusCode, rawHeaders, resume, statusMessage) {
45952- const headers = util.parseHeaders(rawHeaders);
45933+ onResponseStart(controller, statusCode, headers, statusMessage) {
4595345934 const contentLength = headers["content-length"];
4595445935 if (contentLength != null && contentLength > this.#maxSize) {
4595545936 throw new RequestAbortedError(
4595645937 `Response size (${contentLength}) larger than maxSize (${this.#maxSize})`
4595745938 );
4595845939 }
45959- if (this.# aborted) {
45940+ if (this.aborted === true ) {
4596045941 return true;
4596145942 }
45962- return this.#handler.onHeaders(
45963- statusCode,
45964- rawHeaders,
45965- resume,
45966- statusMessage
45967- );
45943+ return super.onResponseStart(controller, statusCode, headers, statusMessage);
4596845944 }
45969- onError( err) {
45945+ onResponseError(controller, err) {
4597045946 if (this.#dumped) {
4597145947 return;
4597245948 }
45973- err = this.#reason ?? err;
45974- this.#handler.onError( err);
45949+ err = this.#controller. reason ?? err;
45950+ super.onResponseError(controller, err);
4597545951 }
45976- onData( chunk) {
45952+ onResponseData(controller, chunk) {
4597745953 this.#size = this.#size + chunk.length;
4597845954 if (this.#size >= this.#maxSize) {
4597945955 this.#dumped = true;
45980- if (this.# aborted) {
45981- this.#handler.onError( this.# reason);
45956+ if (this.aborted === true ) {
45957+ super.onResponseError(controller, this.reason);
4598245958 } else {
45983- this.#handler.onComplete([] );
45959+ super.onResponseEnd(controller, {} );
4598445960 }
4598545961 }
4598645962 return true;
4598745963 }
45988- onComplete( trailers) {
45964+ onResponseEnd(controller, trailers) {
4598945965 if (this.#dumped) {
4599045966 return;
4599145967 }
45992- if (this.#aborted) {
45993- this.#handler.onError( this.reason);
45968+ if (this.#controller. aborted === true ) {
45969+ super.onResponseError(controller, this.reason);
4599445970 return;
4599545971 }
45996- this.#handler.onComplete( trailers);
45972+ super.onResponseEnd(controller, trailers);
4599745973 }
4599845974 };
4599945975 function createDumpInterceptor({ maxSize: defaultMaxSize } = {
@@ -46002,10 +45978,7 @@ var require_dump = __commonJS({
4600245978 return (dispatch) => {
4600345979 return function Intercept(opts, handler2) {
4600445980 const { dumpMaxSize = defaultMaxSize } = opts;
46005- const dumpHandler = new DumpHandler(
46006- { maxSize: dumpMaxSize },
46007- handler2
46008- );
45981+ const dumpHandler = new DumpHandler({ maxSize: dumpMaxSize, signal: opts.signal }, handler2);
4600945982 return dispatch(opts, dumpHandler);
4601045983 };
4601145984 };
@@ -46193,24 +46166,24 @@ var require_dns = __commonJS({
4619346166 #state = null;
4619446167 #opts = null;
4619546168 #dispatch = null;
46196- #handler = null;
4619746169 #origin = null;
46170+ #controller = null;
4619846171 constructor(state, { origin, handler: handler2, dispatch }, opts) {
4619946172 super(handler2);
4620046173 this.#origin = origin;
46201- this.#handler = handler2;
4620246174 this.#opts = { ...opts };
4620346175 this.#state = state;
4620446176 this.#dispatch = dispatch;
4620546177 }
46206- onError( err) {
46178+ onResponseError(controller, err) {
4620746179 switch (err.code) {
4620846180 case "ETIMEDOUT":
4620946181 case "ECONNREFUSED": {
4621046182 if (this.#state.dualStack) {
4621146183 this.#state.runLookup(this.#origin, this.#opts, (err2, newOrigin) => {
4621246184 if (err2) {
46213- return this.#handler.onError(err2);
46185+ super.onResponseError(controller, err2);
46186+ return;
4621446187 }
4621546188 const dispatchOpts = {
4621646189 ...this.#opts,
@@ -46220,13 +46193,13 @@ var require_dns = __commonJS({
4622046193 });
4622146194 return;
4622246195 }
46223- this.#handler.onError( err);
46224- return ;
46196+ super.onResponseError(controller, err);
46197+ break ;
4622546198 }
4622646199 case "ENOTFOUND":
4622746200 this.#state.deleteRecord(this.#origin);
4622846201 default:
46229- this.#handler.onError( err);
46202+ super.onResponseError(controller, err);
4623046203 break;
4623146204 }
4623246205 }
@@ -53582,9 +53555,6 @@ var require_undici2 = __commonJS({
5358253555 const SqliteCacheStore = require_sqlite_cache_store();
5358353556 module.exports.cacheStores.SqliteCacheStore = SqliteCacheStore;
5358453557 } catch (err) {
53585- if (err.code !== "ERR_UNKNOWN_BUILTIN_MODULE") {
53586- throw err;
53587- }
5358853558 }
5358953559 module.exports.buildConnector = buildConnector;
5359053560 module.exports.errors = errors;
0 commit comments