@waitcher/cli 0.2.26 → 0.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/MODEL_CLIENT_NOTICES.txt +6 -51
- package/dist/cli.mjs +458 -189
- package/dist/model-client.mjs +10762 -12545
- package/dist/request-runtime.mjs +446 -179
- package/package.json +1 -1
package/dist/request-runtime.mjs
CHANGED
|
@@ -7838,7 +7838,7 @@ var require_parser_h1 = __commonJS({
|
|
|
7838
7838
|
var EVENT_RANGE_SIZE = 9;
|
|
7839
7839
|
var EVENT_HEADERS_SIZE = 19;
|
|
7840
7840
|
var miloPackage;
|
|
7841
|
-
var useWasmSIMD = process.arch !== "ppc64";
|
|
7841
|
+
var useWasmSIMD = process.arch !== "riscv64" && process.arch !== "ppc64";
|
|
7842
7842
|
if (process.env.UNDICI_NO_WASM_SIMD === "1") {
|
|
7843
7843
|
useWasmSIMD = false;
|
|
7844
7844
|
} else if (process.env.UNDICI_NO_WASM_SIMD === "0") {
|
|
@@ -9117,14 +9117,35 @@ Content-Type: ${value.type || "application/octet-stream"}\r
|
|
|
9117
9117
|
"Response body object should not be disturbed or locked"
|
|
9118
9118
|
);
|
|
9119
9119
|
}
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9120
|
+
if (webidl.is.ReadableStream(object2)) {
|
|
9121
|
+
stream = object2;
|
|
9122
|
+
} else {
|
|
9123
|
+
const reader = ReadableStream.from(object2).getReader();
|
|
9124
|
+
let cancelled = false;
|
|
9125
|
+
stream = new ReadableStream({
|
|
9126
|
+
async pull(controller) {
|
|
9127
|
+
while (true) {
|
|
9128
|
+
const { done, value } = await reader.read();
|
|
9129
|
+
if (cancelled) {
|
|
9130
|
+
return;
|
|
9131
|
+
}
|
|
9132
|
+
if (done) {
|
|
9133
|
+
controller.close();
|
|
9134
|
+
return;
|
|
9135
|
+
}
|
|
9136
|
+
const bytes = isUint8Array(value) ? value : Buffer.from(value);
|
|
9137
|
+
if (bytes.byteLength) {
|
|
9138
|
+
controller.enqueue(bytes);
|
|
9139
|
+
return;
|
|
9140
|
+
}
|
|
9141
|
+
}
|
|
9142
|
+
},
|
|
9143
|
+
cancel(reason) {
|
|
9144
|
+
cancelled = true;
|
|
9145
|
+
return reader.cancel(reason);
|
|
9125
9146
|
}
|
|
9126
|
-
}
|
|
9127
|
-
}
|
|
9147
|
+
}, { highWaterMark: 0 });
|
|
9148
|
+
}
|
|
9128
9149
|
}
|
|
9129
9150
|
if (typeof source === "string" || isUint8Array(source)) {
|
|
9130
9151
|
action = () => source;
|
|
@@ -9356,7 +9377,9 @@ var require_client_h1 = __commonJS({
|
|
|
9356
9377
|
const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0;
|
|
9357
9378
|
let mod;
|
|
9358
9379
|
let useWasmSIMD = true;
|
|
9359
|
-
if (process.arch === "
|
|
9380
|
+
if (process.arch === "riscv64") {
|
|
9381
|
+
useWasmSIMD = false;
|
|
9382
|
+
} else if (process.arch === "ppc64") {
|
|
9360
9383
|
const [major, minor] = process.versions.node.split(".").map((n) => parseInt(n, 10));
|
|
9361
9384
|
if (major < 24 || major === 24 && minor < 12) {
|
|
9362
9385
|
useWasmSIMD = false;
|
|
@@ -10677,7 +10700,6 @@ var require_client_h2 = __commonJS({
|
|
|
10677
10700
|
} = require_symbols();
|
|
10678
10701
|
var { channels } = require_diagnostics();
|
|
10679
10702
|
var kOpenStreams = /* @__PURE__ */ Symbol("open streams");
|
|
10680
|
-
var kRequestStreamId = /* @__PURE__ */ Symbol("request stream id");
|
|
10681
10703
|
var kRequestStream = /* @__PURE__ */ Symbol("request stream");
|
|
10682
10704
|
var kRequestStreamCleanup = /* @__PURE__ */ Symbol("request stream cleanup");
|
|
10683
10705
|
var kRequestStreamState = /* @__PURE__ */ Symbol("request stream state");
|
|
@@ -10685,6 +10707,7 @@ var require_client_h2 = __commonJS({
|
|
|
10685
10707
|
var kGoAwayReplayAttempts = /* @__PURE__ */ Symbol("goaway replay attempts");
|
|
10686
10708
|
var kRefusedStreamRetry = /* @__PURE__ */ Symbol("refused stream retry");
|
|
10687
10709
|
var MAX_GOAWAY_REPLAY_ATTEMPTS = 1;
|
|
10710
|
+
var HTTP2_FRAME_TYPE_HEADERS = 1;
|
|
10688
10711
|
var MIN_PROBE_TIMEOUT = 1e3;
|
|
10689
10712
|
var extractBody;
|
|
10690
10713
|
var http2;
|
|
@@ -10736,14 +10759,14 @@ var require_client_h2 = __commonJS({
|
|
|
10736
10759
|
if (request == null) {
|
|
10737
10760
|
continue;
|
|
10738
10761
|
}
|
|
10739
|
-
|
|
10762
|
+
const streamId = request[kRequestStream]?.id;
|
|
10763
|
+
if (typeof streamId !== "number" || streamId > maxAcceptedStreamID) {
|
|
10740
10764
|
return i;
|
|
10741
10765
|
}
|
|
10742
10766
|
}
|
|
10743
10767
|
return client[kPendingIdx];
|
|
10744
10768
|
}
|
|
10745
10769
|
function detachRequestFromStream(request) {
|
|
10746
|
-
request[kRequestStreamId] = null;
|
|
10747
10770
|
request[kRequestStream] = null;
|
|
10748
10771
|
request[kRequestStreamCleanup] = null;
|
|
10749
10772
|
}
|
|
@@ -10752,7 +10775,6 @@ var require_client_h2 = __commonJS({
|
|
|
10752
10775
|
const previousStream = request[kRequestStream];
|
|
10753
10776
|
detachRequestFromStream(request);
|
|
10754
10777
|
previousCleanup?.(previousStream);
|
|
10755
|
-
request[kRequestStreamId] = stream.id;
|
|
10756
10778
|
request[kRequestStream] = stream;
|
|
10757
10779
|
request[kRequestStreamCleanup] = cleanup;
|
|
10758
10780
|
}
|
|
@@ -10821,7 +10843,8 @@ var require_client_h2 = __commonJS({
|
|
|
10821
10843
|
closeStreamSession(stream);
|
|
10822
10844
|
}
|
|
10823
10845
|
if (!stream.destroyed && !stream.closed) {
|
|
10824
|
-
stream.
|
|
10846
|
+
stream.off("error", noop);
|
|
10847
|
+
stream.on("error", noop);
|
|
10825
10848
|
}
|
|
10826
10849
|
}
|
|
10827
10850
|
function connectH2(client, socket) {
|
|
@@ -11156,14 +11179,12 @@ var require_client_h2 = __commonJS({
|
|
|
11156
11179
|
}
|
|
11157
11180
|
}
|
|
11158
11181
|
}
|
|
11159
|
-
for (let i = 0; i < streamsToClose.length; i++) {
|
|
11160
|
-
closeStream(streamsToClose[i]);
|
|
11161
|
-
}
|
|
11162
11182
|
if (pendingIdx !== previousPendingIdx) {
|
|
11163
11183
|
const remainingPendingRequests = client[kQueue].slice(previousPendingIdx);
|
|
11164
11184
|
client[kQueue].length = pendingIdx;
|
|
11165
11185
|
client[kQueue].push(...retriableRequests, ...remainingPendingRequests);
|
|
11166
11186
|
}
|
|
11187
|
+
client[kPendingIdx] = pendingIdx;
|
|
11167
11188
|
if (client[kHTTP2Session] === this) {
|
|
11168
11189
|
client[kSocket] = null;
|
|
11169
11190
|
client[kHTTPContext] = null;
|
|
@@ -11175,10 +11196,12 @@ var require_client_h2 = __commonJS({
|
|
|
11175
11196
|
clearHttp2IdleTimeout(this);
|
|
11176
11197
|
clearNoStreamsTimeout(this);
|
|
11177
11198
|
clearHttp2ProbeTimeout(this);
|
|
11199
|
+
for (let i = 0; i < streamsToClose.length; i++) {
|
|
11200
|
+
closeStream(streamsToClose[i]);
|
|
11201
|
+
}
|
|
11178
11202
|
if (!this.closed && !this.destroyed) {
|
|
11179
11203
|
this.close();
|
|
11180
11204
|
}
|
|
11181
|
-
client[kPendingIdx] = pendingIdx;
|
|
11182
11205
|
client.emit("disconnect", client[kUrl], [client], err);
|
|
11183
11206
|
client[kResume]();
|
|
11184
11207
|
}
|
|
@@ -11254,7 +11277,6 @@ var require_client_h2 = __commonJS({
|
|
|
11254
11277
|
}
|
|
11255
11278
|
}
|
|
11256
11279
|
function onUpgradeStreamClose() {
|
|
11257
|
-
this.off("error", noop);
|
|
11258
11280
|
const state = this[kRequestStreamState];
|
|
11259
11281
|
this[kRequestStreamState] = null;
|
|
11260
11282
|
failUpgradeStream(state, new InformationalError("HTTP/2: stream closed before response headers"));
|
|
@@ -11327,7 +11349,7 @@ var require_client_h2 = __commonJS({
|
|
|
11327
11349
|
}
|
|
11328
11350
|
removeUpgradeStreamListeners(stream);
|
|
11329
11351
|
if (!stream.destroyed && !stream.closed) {
|
|
11330
|
-
stream.
|
|
11352
|
+
stream.on("error", noop);
|
|
11331
11353
|
}
|
|
11332
11354
|
}
|
|
11333
11355
|
function failUpgradeStream(state, err) {
|
|
@@ -11621,7 +11643,7 @@ var require_client_h2 = __commonJS({
|
|
|
11621
11643
|
}
|
|
11622
11644
|
if (!stream.destroyed && !stream.closed) {
|
|
11623
11645
|
removeRequestStreamListeners(stream);
|
|
11624
|
-
stream.
|
|
11646
|
+
stream.on("error", noop);
|
|
11625
11647
|
}
|
|
11626
11648
|
}
|
|
11627
11649
|
function onData(chunk) {
|
|
@@ -11734,13 +11756,25 @@ var require_client_h2 = __commonJS({
|
|
|
11734
11756
|
return false;
|
|
11735
11757
|
}
|
|
11736
11758
|
request[kRefusedStreamRetry] = true;
|
|
11759
|
+
requeueStreamRequest(client, state);
|
|
11760
|
+
return true;
|
|
11761
|
+
}
|
|
11762
|
+
function retryUnsentStream(state) {
|
|
11763
|
+
const { client, request, session } = state;
|
|
11764
|
+
if (!session[kReceivedGoAway] || state.responseReceived || request.aborted || request.completed || !canReplayRequest(request) || !registerGoAwayRefusal(request)) {
|
|
11765
|
+
return false;
|
|
11766
|
+
}
|
|
11767
|
+
requeueStreamRequest(client, state);
|
|
11768
|
+
return true;
|
|
11769
|
+
}
|
|
11770
|
+
function requeueStreamRequest(client, state) {
|
|
11771
|
+
const { request } = state;
|
|
11737
11772
|
detachRequestStreamForClose(request);
|
|
11738
11773
|
state.stream = null;
|
|
11739
11774
|
state.requestFinalized = true;
|
|
11740
11775
|
completeRequest(client, request);
|
|
11741
11776
|
client[kQueue].splice(client[kPendingIdx], 0, request);
|
|
11742
11777
|
client[kResume]();
|
|
11743
|
-
return true;
|
|
11744
11778
|
}
|
|
11745
11779
|
function onError(err) {
|
|
11746
11780
|
const stream = this;
|
|
@@ -11749,6 +11783,7 @@ var require_client_h2 = __commonJS({
|
|
|
11749
11783
|
return;
|
|
11750
11784
|
}
|
|
11751
11785
|
stream.off("error", onError);
|
|
11786
|
+
stream.on("error", noop);
|
|
11752
11787
|
if (state.responseContentLength != null && state.bytesRead !== state.responseContentLength) {
|
|
11753
11788
|
err = new ResponseContentLengthMismatchError();
|
|
11754
11789
|
}
|
|
@@ -11767,6 +11802,9 @@ var require_client_h2 = __commonJS({
|
|
|
11767
11802
|
return;
|
|
11768
11803
|
}
|
|
11769
11804
|
stream.off("frameError", onFrameError);
|
|
11805
|
+
if (type === HTTP2_FRAME_TYPE_HEADERS && retryUnsentStream(state)) {
|
|
11806
|
+
return;
|
|
11807
|
+
}
|
|
11770
11808
|
state.abort(new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`));
|
|
11771
11809
|
}
|
|
11772
11810
|
function onAborted() {
|
|
@@ -17019,13 +17057,18 @@ var require_mock_utils = __commonJS({
|
|
|
17019
17057
|
if (typeof path2 !== "string") {
|
|
17020
17058
|
return path2;
|
|
17021
17059
|
}
|
|
17060
|
+
const queryIndex = path2.indexOf("?");
|
|
17061
|
+
const search = queryIndex === -1 ? "" : path2.slice(queryIndex);
|
|
17062
|
+
if (queryIndex !== -1) {
|
|
17063
|
+
path2 = path2.slice(0, queryIndex);
|
|
17064
|
+
}
|
|
17022
17065
|
while (path2.endsWith("/")) {
|
|
17023
17066
|
path2 = path2.slice(0, -1);
|
|
17024
17067
|
}
|
|
17025
17068
|
if (path2.length === 0) {
|
|
17026
17069
|
path2 = "/";
|
|
17027
17070
|
}
|
|
17028
|
-
return path2;
|
|
17071
|
+
return path2 + search;
|
|
17029
17072
|
}
|
|
17030
17073
|
function buildKey(opts) {
|
|
17031
17074
|
const { path: path2, method, body: body2, headers, query } = opts;
|
|
@@ -17112,6 +17155,9 @@ var require_mock_utils = __commonJS({
|
|
|
17112
17155
|
paused: false,
|
|
17113
17156
|
rawHeaders: null,
|
|
17114
17157
|
rawTrailers: null,
|
|
17158
|
+
get aborted() {
|
|
17159
|
+
return aborted2;
|
|
17160
|
+
},
|
|
17115
17161
|
pause() {
|
|
17116
17162
|
this.paused = true;
|
|
17117
17163
|
},
|
|
@@ -18993,8 +19039,11 @@ var require_decorator_handler = __commonJS({
|
|
|
18993
19039
|
onResponseStart(...args) {
|
|
18994
19040
|
assert2(!this.#onCompleteCalled);
|
|
18995
19041
|
assert2(!this.#onErrorCalled);
|
|
18996
|
-
|
|
18997
|
-
|
|
19042
|
+
const statusCode = args[1];
|
|
19043
|
+
if (statusCode >= 200) {
|
|
19044
|
+
assert2(!this.#onResponseStartCalled);
|
|
19045
|
+
this.#onResponseStartCalled = true;
|
|
19046
|
+
}
|
|
18998
19047
|
return this.#handler.onResponseStart?.(...args);
|
|
18999
19048
|
}
|
|
19000
19049
|
onResponseData(...args) {
|
|
@@ -19114,7 +19163,11 @@ var require_redirect_handler = __commonJS({
|
|
|
19114
19163
|
this.handler.onResponseStart?.(controller, statusCode, headers, statusMessage);
|
|
19115
19164
|
return;
|
|
19116
19165
|
}
|
|
19117
|
-
this.history[kRedirectCacheControl].push(
|
|
19166
|
+
this.history[kRedirectCacheControl].push({
|
|
19167
|
+
statusCode,
|
|
19168
|
+
headers: { ...headers },
|
|
19169
|
+
receivedAt: Date.now()
|
|
19170
|
+
});
|
|
19118
19171
|
const baseUrl = requestOrigin ? new URL(this.opts.path, requestOrigin) : void 0;
|
|
19119
19172
|
const { origin, pathname, search } = util.parseURL(new URL(this.location, baseUrl));
|
|
19120
19173
|
const path2 = search ? `${pathname}${search}` : pathname;
|
|
@@ -19182,9 +19235,17 @@ var require_redirect_handler = __commonJS({
|
|
|
19182
19235
|
function cleanRequestHeaders(headers, removeContent, unknownOrigin, stripHeaders, stripHeadersOnCrossOrigin) {
|
|
19183
19236
|
const ret = [];
|
|
19184
19237
|
if (Array.isArray(headers)) {
|
|
19185
|
-
|
|
19186
|
-
|
|
19187
|
-
|
|
19238
|
+
if (headers.length > 0 && Array.isArray(headers[0])) {
|
|
19239
|
+
for (const [key, value] of headers) {
|
|
19240
|
+
if (!shouldRemoveHeader(key, removeContent, unknownOrigin, stripHeaders, stripHeadersOnCrossOrigin)) {
|
|
19241
|
+
ret.push(key, value);
|
|
19242
|
+
}
|
|
19243
|
+
}
|
|
19244
|
+
} else {
|
|
19245
|
+
for (let i = 0; i < headers.length; i += 2) {
|
|
19246
|
+
if (!shouldRemoveHeader(headers[i], removeContent, unknownOrigin, stripHeaders, stripHeadersOnCrossOrigin)) {
|
|
19247
|
+
ret.push(headers[i], headers[i + 1]);
|
|
19248
|
+
}
|
|
19188
19249
|
}
|
|
19189
19250
|
}
|
|
19190
19251
|
} else if (headers && typeof headers === "object") {
|
|
@@ -21048,6 +21109,15 @@ var require_cache_handler = __commonJS({
|
|
|
21048
21109
|
}
|
|
21049
21110
|
return false;
|
|
21050
21111
|
}
|
|
21112
|
+
function appendVaryValues(target, varyValue) {
|
|
21113
|
+
if (Array.isArray(varyValue)) {
|
|
21114
|
+
for (let i = 0; i < varyValue.length; i++) {
|
|
21115
|
+
target.push(varyValue[i]);
|
|
21116
|
+
}
|
|
21117
|
+
} else if (varyValue != null) {
|
|
21118
|
+
target.push(varyValue);
|
|
21119
|
+
}
|
|
21120
|
+
}
|
|
21051
21121
|
function appendConnectionHeaderTokens(headersToRemove, connectionHeader) {
|
|
21052
21122
|
const values = Array.isArray(connectionHeader) ? connectionHeader : [connectionHeader];
|
|
21053
21123
|
for (let i = 0; i < values.length; i++) {
|
|
@@ -21109,6 +21179,9 @@ var require_cache_handler = __commonJS({
|
|
|
21109
21179
|
deleteLocationTargets(store, cacheKey, resHeaders.location);
|
|
21110
21180
|
deleteLocationTargets(store, cacheKey, resHeaders["content-location"]);
|
|
21111
21181
|
}
|
|
21182
|
+
function requestCarriesCredentials(headers) {
|
|
21183
|
+
return headers != null && (Object.hasOwn(headers, "authorization") || Object.hasOwn(headers, "cookie") || Object.hasOwn(headers, "proxy-authorization"));
|
|
21184
|
+
}
|
|
21112
21185
|
var CacheHandler = class {
|
|
21113
21186
|
/**
|
|
21114
21187
|
* @type {import('../../types/cache-interceptor.d.ts').default.CacheKey}
|
|
@@ -21141,7 +21214,7 @@ var require_cache_handler = __commonJS({
|
|
|
21141
21214
|
/**
|
|
21142
21215
|
* The URLs visited while following redirects, shared by reference from the
|
|
21143
21216
|
* redirect handler through the request context. Carries the suppressed hops'
|
|
21144
|
-
*
|
|
21217
|
+
* status/headers under {@link kRedirectCacheControl}.
|
|
21145
21218
|
* @type {URL[] | undefined}
|
|
21146
21219
|
*/
|
|
21147
21220
|
#history;
|
|
@@ -21191,21 +21264,29 @@ var require_cache_handler = __commonJS({
|
|
|
21191
21264
|
invalidateUnsafeRequest(this.#store, this.#cacheKey, resHeaders);
|
|
21192
21265
|
return downstreamOnHeaders();
|
|
21193
21266
|
}
|
|
21194
|
-
if (this.#history && this.#history.length >
|
|
21195
|
-
|
|
21196
|
-
if (!sameOrigin(finalUrl.origin, this.#cacheKey.origin)) {
|
|
21197
|
-
return downstreamOnHeaders();
|
|
21198
|
-
}
|
|
21267
|
+
if (this.#history && this.#history.length > 1 && requestCarriesCredentials(this.#cacheKey.headers)) {
|
|
21268
|
+
return downstreamOnHeaders();
|
|
21199
21269
|
}
|
|
21200
|
-
|
|
21201
|
-
|
|
21202
|
-
|
|
21203
|
-
const hopDirectives = hopCacheControl ? parseCacheControlHeader(hopCacheControl) : {};
|
|
21204
|
-
if (hopDirectives["no-store"] === true || this.#cacheType === "shared" && hopDirectives.private === true) {
|
|
21270
|
+
if (this.#history && this.#history.length > 0) {
|
|
21271
|
+
for (const hopUrl of this.#history) {
|
|
21272
|
+
if (!sameOrigin(hopUrl.origin, this.#cacheKey.origin)) {
|
|
21205
21273
|
return downstreamOnHeaders();
|
|
21206
21274
|
}
|
|
21207
21275
|
}
|
|
21208
21276
|
}
|
|
21277
|
+
const now = Date.now();
|
|
21278
|
+
const redirectHopInfo = this.#history?.[kRedirectCacheControl];
|
|
21279
|
+
const redirectPolicy = redirectHopInfo?.length > 0 ? getRedirectPolicy(
|
|
21280
|
+
this.#cacheType,
|
|
21281
|
+
this.#cacheKey.method,
|
|
21282
|
+
redirectHopInfo,
|
|
21283
|
+
this.#cacheKey.headers,
|
|
21284
|
+
this.#cacheByDefault,
|
|
21285
|
+
now
|
|
21286
|
+
) : void 0;
|
|
21287
|
+
if (redirectHopInfo?.length > 0 && redirectPolicy === void 0) {
|
|
21288
|
+
return downstreamOnHeaders();
|
|
21289
|
+
}
|
|
21209
21290
|
const cacheControlHeader = resHeaders["cache-control"];
|
|
21210
21291
|
const cacheControlDirectives = cacheControlHeader ? parseCacheControlHeader(cacheControlHeader) : {};
|
|
21211
21292
|
if (revalidationResponseDisallowsCachedReuse(this.#cacheType, resHeaders, cacheControlDirectives)) {
|
|
@@ -21225,7 +21306,6 @@ var require_cache_handler = __commonJS({
|
|
|
21225
21306
|
}
|
|
21226
21307
|
return downstreamOnHeaders();
|
|
21227
21308
|
}
|
|
21228
|
-
const now = Date.now();
|
|
21229
21309
|
const resAge = Object.hasOwn(resHeaders, "age") ? getAge(resHeaders.age) : void 0;
|
|
21230
21310
|
if (resAge !== void 0 && resAge >= MAX_RESPONSE_AGE) {
|
|
21231
21311
|
deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
|
|
@@ -21248,27 +21328,53 @@ var require_cache_handler = __commonJS({
|
|
|
21248
21328
|
return downstreamOnHeaders();
|
|
21249
21329
|
}
|
|
21250
21330
|
const baseTime = now - currentAge;
|
|
21251
|
-
|
|
21331
|
+
let absoluteStaleAt = staleAt + baseTime;
|
|
21332
|
+
if (redirectPolicy !== void 0) {
|
|
21333
|
+
absoluteStaleAt = Math.min(absoluteStaleAt, redirectPolicy.staleAt);
|
|
21334
|
+
}
|
|
21252
21335
|
if (now >= absoluteStaleAt && !revalidationOnly) {
|
|
21253
21336
|
deleteCachedValueIfNotModified(statusCode, this.#store, this.#cacheKey);
|
|
21254
21337
|
return downstreamOnHeaders();
|
|
21255
21338
|
}
|
|
21256
21339
|
let varyDirectives;
|
|
21257
|
-
|
|
21258
|
-
|
|
21259
|
-
|
|
21260
|
-
|
|
21340
|
+
const combinedVary = [];
|
|
21341
|
+
if (redirectHopInfo) {
|
|
21342
|
+
for (const hop of redirectHopInfo) {
|
|
21343
|
+
appendVaryValues(combinedVary, hop?.headers?.vary);
|
|
21344
|
+
}
|
|
21345
|
+
}
|
|
21346
|
+
appendVaryValues(combinedVary, resHeaders.vary);
|
|
21347
|
+
if (combinedVary.length > 0) {
|
|
21348
|
+
for (const varyHeader of combinedVary) {
|
|
21349
|
+
if (hasVaryStar(varyHeader)) {
|
|
21350
|
+
return downstreamOnHeaders();
|
|
21351
|
+
}
|
|
21352
|
+
}
|
|
21353
|
+
if (this.#cacheKey.headers) {
|
|
21354
|
+
varyDirectives = parseVaryHeader(combinedVary, this.#cacheKey.headers);
|
|
21355
|
+
if (!varyDirectives) {
|
|
21356
|
+
return downstreamOnHeaders();
|
|
21357
|
+
}
|
|
21358
|
+
}
|
|
21359
|
+
}
|
|
21360
|
+
let effectiveCacheControlDirectives = cacheControlDirectives;
|
|
21361
|
+
if (redirectPolicy !== void 0) {
|
|
21362
|
+
effectiveCacheControlDirectives = { ...cacheControlDirectives };
|
|
21363
|
+
delete effectiveCacheControlDirectives["stale-while-revalidate"];
|
|
21364
|
+
delete effectiveCacheControlDirectives["stale-if-error"];
|
|
21365
|
+
if (redirectPolicy.requiresRevalidation === true) {
|
|
21366
|
+
effectiveCacheControlDirectives["proxy-revalidate"] = true;
|
|
21261
21367
|
}
|
|
21262
21368
|
}
|
|
21263
21369
|
const cachedAt = baseTime;
|
|
21264
|
-
const deleteAt = determineDeleteAt(baseTime, now,
|
|
21370
|
+
const deleteAt = determineDeleteAt(baseTime, now, effectiveCacheControlDirectives, absoluteStaleAt);
|
|
21265
21371
|
const strippedHeaders = stripNecessaryHeaders(resHeaders, cacheControlDirectives);
|
|
21266
21372
|
const value = {
|
|
21267
21373
|
statusCode,
|
|
21268
21374
|
statusMessage,
|
|
21269
21375
|
headers: strippedHeaders,
|
|
21270
21376
|
vary: varyDirectives,
|
|
21271
|
-
cacheControlDirectives,
|
|
21377
|
+
cacheControlDirectives: effectiveCacheControlDirectives,
|
|
21272
21378
|
cachedAt,
|
|
21273
21379
|
staleAt: absoluteStaleAt,
|
|
21274
21380
|
deleteAt
|
|
@@ -21282,6 +21388,13 @@ var require_cache_handler = __commonJS({
|
|
|
21282
21388
|
done = true;
|
|
21283
21389
|
this.#downstreamController.release();
|
|
21284
21390
|
};
|
|
21391
|
+
const failReplay = (err) => {
|
|
21392
|
+
if (done) {
|
|
21393
|
+
return;
|
|
21394
|
+
}
|
|
21395
|
+
done = true;
|
|
21396
|
+
controller.abort(err);
|
|
21397
|
+
};
|
|
21285
21398
|
const handle304 = (cachedValue) => {
|
|
21286
21399
|
if (!cachedValue) {
|
|
21287
21400
|
downstreamOnHeaders();
|
|
@@ -21305,14 +21418,18 @@ var require_cache_handler = __commonJS({
|
|
|
21305
21418
|
if (done) {
|
|
21306
21419
|
return;
|
|
21307
21420
|
}
|
|
21308
|
-
|
|
21309
|
-
const
|
|
21310
|
-
|
|
21311
|
-
|
|
21312
|
-
|
|
21421
|
+
try {
|
|
21422
|
+
for (const chunk of bodyIterator) {
|
|
21423
|
+
const full = this.#writeStream?.write(chunk) === false;
|
|
21424
|
+
this.#handler.onResponseData?.(this.#downstreamController, chunk);
|
|
21425
|
+
if (full) {
|
|
21426
|
+
return;
|
|
21427
|
+
}
|
|
21313
21428
|
}
|
|
21429
|
+
finish304();
|
|
21430
|
+
} catch (err) {
|
|
21431
|
+
failReplay(err);
|
|
21314
21432
|
}
|
|
21315
|
-
finish304();
|
|
21316
21433
|
};
|
|
21317
21434
|
this.#writeStream.on("error", function() {
|
|
21318
21435
|
handler.#writeStream = void 0;
|
|
@@ -21329,8 +21446,13 @@ var require_cache_handler = __commonJS({
|
|
|
21329
21446
|
streamCachedBody();
|
|
21330
21447
|
} else if (typeof cachedValue.body.on === "function") {
|
|
21331
21448
|
cachedValue.body.on("data", (chunk) => {
|
|
21332
|
-
|
|
21333
|
-
|
|
21449
|
+
try {
|
|
21450
|
+
this.#writeStream?.write(chunk);
|
|
21451
|
+
this.#handler.onResponseData?.(this.#downstreamController, chunk);
|
|
21452
|
+
} catch (err) {
|
|
21453
|
+
cachedValue.body.destroy();
|
|
21454
|
+
failReplay(err);
|
|
21455
|
+
}
|
|
21334
21456
|
}).on("end", () => {
|
|
21335
21457
|
this.#writeStream?.end();
|
|
21336
21458
|
finish304();
|
|
@@ -21447,6 +21569,74 @@ var require_cache_handler = __commonJS({
|
|
|
21447
21569
|
}
|
|
21448
21570
|
return true;
|
|
21449
21571
|
}
|
|
21572
|
+
function getRedirectPolicy(cacheType, method, redirectHops, reqHeaders, cacheByDefault, now) {
|
|
21573
|
+
let staleAt = Infinity;
|
|
21574
|
+
let requiresRevalidation = false;
|
|
21575
|
+
for (const hop of redirectHops) {
|
|
21576
|
+
const hopPolicy = getRedirectHopPolicy(cacheType, method, hop, reqHeaders, cacheByDefault);
|
|
21577
|
+
if (hopPolicy === void 0 || hopPolicy.staleAt <= now) {
|
|
21578
|
+
return void 0;
|
|
21579
|
+
}
|
|
21580
|
+
staleAt = Math.min(staleAt, hopPolicy.staleAt);
|
|
21581
|
+
requiresRevalidation ||= hopPolicy.requiresRevalidation;
|
|
21582
|
+
}
|
|
21583
|
+
return { staleAt, requiresRevalidation };
|
|
21584
|
+
}
|
|
21585
|
+
function getRedirectHopPolicy(cacheType, method, hop, reqHeaders, cacheByDefault) {
|
|
21586
|
+
if (!Number.isInteger(hop?.statusCode) || !Number.isFinite(hop?.receivedAt)) {
|
|
21587
|
+
return void 0;
|
|
21588
|
+
}
|
|
21589
|
+
const hopHeaders = hop.headers ?? {};
|
|
21590
|
+
const cacheControlHeader = hopHeaders["cache-control"];
|
|
21591
|
+
const hopCacheControl = cacheControlHeader ? parseCacheControlHeader(cacheControlHeader) : {};
|
|
21592
|
+
if (hopHeaders.vary && hasVaryStar(hopHeaders.vary)) {
|
|
21593
|
+
return void 0;
|
|
21594
|
+
}
|
|
21595
|
+
if (hopCacheControl["no-store"] === true) {
|
|
21596
|
+
return void 0;
|
|
21597
|
+
}
|
|
21598
|
+
if (cacheType === "shared" && Object.hasOwn(hopCacheControl, "private")) {
|
|
21599
|
+
return void 0;
|
|
21600
|
+
}
|
|
21601
|
+
if (Object.hasOwn(hopCacheControl, "no-cache") || hopCacheControl["must-revalidate"] === true || cacheType === "shared" && hopCacheControl["proxy-revalidate"] === true) {
|
|
21602
|
+
return void 0;
|
|
21603
|
+
}
|
|
21604
|
+
const heuristicallyCacheable = hopHeaders["last-modified"] && arrayIncludes(HEURISTICALLY_CACHEABLE_STATUS_CODES, hop.statusCode);
|
|
21605
|
+
if (!cacheControlHeader && !hopHeaders.expires && !heuristicallyCacheable && !cacheByDefault) {
|
|
21606
|
+
return void 0;
|
|
21607
|
+
}
|
|
21608
|
+
if (!canCacheResponse(cacheType, method, hop.statusCode, hopHeaders, hopCacheControl, reqHeaders)) {
|
|
21609
|
+
return void 0;
|
|
21610
|
+
}
|
|
21611
|
+
const age = Object.hasOwn(hopHeaders, "age") ? getAge(hopHeaders.age) : void 0;
|
|
21612
|
+
if (age !== void 0 && age >= MAX_RESPONSE_AGE) {
|
|
21613
|
+
return void 0;
|
|
21614
|
+
}
|
|
21615
|
+
const responseDate = Object.hasOwn(hopHeaders, "date") ? getDate(hopHeaders.date) : void 0;
|
|
21616
|
+
if (responseDate === null) {
|
|
21617
|
+
return void 0;
|
|
21618
|
+
}
|
|
21619
|
+
const apparentAge = responseDate ? Math.max(0, hop.receivedAt - responseDate.getTime()) : 0;
|
|
21620
|
+
const currentAge = Math.max(apparentAge, age ?? 0);
|
|
21621
|
+
const hasValidator = typeof hopHeaders.etag === "string" && isEtagUsable(hopHeaders.etag) || typeof hopHeaders["last-modified"] === "string";
|
|
21622
|
+
const freshnessLifetime = determineStaleAt(
|
|
21623
|
+
cacheType,
|
|
21624
|
+
hop.receivedAt,
|
|
21625
|
+
age,
|
|
21626
|
+
hopHeaders,
|
|
21627
|
+
responseDate,
|
|
21628
|
+
hopCacheControl,
|
|
21629
|
+
hasValidator
|
|
21630
|
+
) ?? cacheByDefault;
|
|
21631
|
+
if (freshnessLifetime === void 0) {
|
|
21632
|
+
return void 0;
|
|
21633
|
+
}
|
|
21634
|
+
return {
|
|
21635
|
+
staleAt: hop.receivedAt - currentAge + freshnessLifetime,
|
|
21636
|
+
// RFC 9111 §5.2.2.10: s-maxage implies proxy-revalidate for shared caches.
|
|
21637
|
+
requiresRevalidation: cacheType === "shared" && Object.hasOwn(hopCacheControl, "s-maxage")
|
|
21638
|
+
};
|
|
21639
|
+
}
|
|
21450
21640
|
function getDate(dateHeader) {
|
|
21451
21641
|
let dateValue = dateHeader;
|
|
21452
21642
|
if (Array.isArray(dateValue)) {
|
|
@@ -21948,7 +22138,8 @@ var require_cache2 = __commonJS({
|
|
|
21948
22138
|
normalizeHeaders,
|
|
21949
22139
|
parseCacheControlHeader,
|
|
21950
22140
|
isInvalidOrWildcardVaryHeader,
|
|
21951
|
-
parseVaryHeader
|
|
22141
|
+
parseVaryHeader,
|
|
22142
|
+
isEtagUsable
|
|
21952
22143
|
} = require_cache();
|
|
21953
22144
|
var { AbortError } = require_errors();
|
|
21954
22145
|
var { parseHttpDate } = require_date();
|
|
@@ -22068,6 +22259,34 @@ var require_cache2 = __commonJS({
|
|
|
22068
22259
|
}
|
|
22069
22260
|
return headers;
|
|
22070
22261
|
}
|
|
22262
|
+
function revalidationTargetMatchesCacheKey(cacheKey, context) {
|
|
22263
|
+
const history = context?.history;
|
|
22264
|
+
if (!Array.isArray(history) || history.length === 0) {
|
|
22265
|
+
return true;
|
|
22266
|
+
}
|
|
22267
|
+
try {
|
|
22268
|
+
const cachedUrl = new URL(cacheKey.path, cacheKey.origin);
|
|
22269
|
+
const responseUrl = history[history.length - 1];
|
|
22270
|
+
return responseUrl.origin === cachedUrl.origin && responseUrl.pathname === cachedUrl.pathname && responseUrl.search === cachedUrl.search;
|
|
22271
|
+
} catch {
|
|
22272
|
+
return false;
|
|
22273
|
+
}
|
|
22274
|
+
}
|
|
22275
|
+
function revalidationEtagMatchesCachedValue(result, headers) {
|
|
22276
|
+
if (!Object.hasOwn(headers, "etag")) {
|
|
22277
|
+
return true;
|
|
22278
|
+
}
|
|
22279
|
+
const responseEtag = headers.etag;
|
|
22280
|
+
const cachedEtag = result.etag;
|
|
22281
|
+
if (typeof responseEtag !== "string" || typeof cachedEtag !== "string" || !isEtagUsable(responseEtag) || !isEtagUsable(cachedEtag)) {
|
|
22282
|
+
return false;
|
|
22283
|
+
}
|
|
22284
|
+
if (!responseEtag.startsWith("W/")) {
|
|
22285
|
+
return responseEtag === cachedEtag;
|
|
22286
|
+
}
|
|
22287
|
+
const cachedOpaqueTag = cachedEtag.startsWith("W/") ? cachedEtag.slice(2) : cachedEtag;
|
|
22288
|
+
return responseEtag.slice(2) === cachedOpaqueTag;
|
|
22289
|
+
}
|
|
22071
22290
|
function isStale(result, cacheControlDirectives, cacheType) {
|
|
22072
22291
|
const now = Date.now();
|
|
22073
22292
|
if (now > result.staleAt || result.staleAt <= result.cachedAt) {
|
|
@@ -22165,18 +22384,23 @@ var require_cache2 = __commonJS({
|
|
|
22165
22384
|
};
|
|
22166
22385
|
stream.on("error", function(err) {
|
|
22167
22386
|
if (!this.readableEnded) {
|
|
22168
|
-
|
|
22169
|
-
handler.onResponseError(controller, err);
|
|
22170
|
-
} else {
|
|
22171
|
-
throw err;
|
|
22172
|
-
}
|
|
22387
|
+
handler.onResponseError?.(controller, err);
|
|
22173
22388
|
}
|
|
22174
22389
|
}).on("close", function() {
|
|
22175
22390
|
if (!this.errored) {
|
|
22176
|
-
|
|
22391
|
+
try {
|
|
22392
|
+
handler.onResponseEnd?.(controller, {});
|
|
22393
|
+
} catch (err) {
|
|
22394
|
+
handler.onResponseError?.(controller, err);
|
|
22395
|
+
}
|
|
22177
22396
|
}
|
|
22178
22397
|
});
|
|
22179
|
-
|
|
22398
|
+
try {
|
|
22399
|
+
handler.onRequestStart?.(controller, context);
|
|
22400
|
+
} catch (err) {
|
|
22401
|
+
stream.destroy(err);
|
|
22402
|
+
return;
|
|
22403
|
+
}
|
|
22180
22404
|
if (stream.destroyed) {
|
|
22181
22405
|
return;
|
|
22182
22406
|
}
|
|
@@ -22185,12 +22409,21 @@ var require_cache2 = __commonJS({
|
|
|
22185
22409
|
headers.warning = '110 - "response is stale"';
|
|
22186
22410
|
}
|
|
22187
22411
|
controller.rawHeaders = util.toRawHeaders(headers);
|
|
22188
|
-
|
|
22412
|
+
try {
|
|
22413
|
+
handler.onResponseStart?.(controller, result.statusCode, headers, result.statusMessage);
|
|
22414
|
+
} catch (err) {
|
|
22415
|
+
stream.destroy(err);
|
|
22416
|
+
return;
|
|
22417
|
+
}
|
|
22189
22418
|
if (opts.method === "HEAD") {
|
|
22190
22419
|
stream.destroy();
|
|
22191
22420
|
} else {
|
|
22192
22421
|
stream.on("data", function(chunk) {
|
|
22193
|
-
|
|
22422
|
+
try {
|
|
22423
|
+
handler.onResponseData?.(controller, chunk);
|
|
22424
|
+
} catch (err) {
|
|
22425
|
+
stream.destroy(err);
|
|
22426
|
+
}
|
|
22194
22427
|
});
|
|
22195
22428
|
}
|
|
22196
22429
|
}
|
|
@@ -22253,6 +22486,13 @@ var require_cache2 = __commonJS({
|
|
|
22253
22486
|
}
|
|
22254
22487
|
}
|
|
22255
22488
|
const headers = makeRevalidationHeaders(opts, result);
|
|
22489
|
+
const refetch = () => {
|
|
22490
|
+
if (util.isStream(result.body)) {
|
|
22491
|
+
result.body.on("error", nop).destroy();
|
|
22492
|
+
}
|
|
22493
|
+
deleteCachedValue(globalOpts.store, cacheKey);
|
|
22494
|
+
return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
22495
|
+
};
|
|
22256
22496
|
return dispatch(
|
|
22257
22497
|
{
|
|
22258
22498
|
...opts,
|
|
@@ -22262,21 +22502,13 @@ var require_cache2 = __commonJS({
|
|
|
22262
22502
|
(success2, context, statusCode, headers2) => {
|
|
22263
22503
|
if (success2) {
|
|
22264
22504
|
if (statusCode === 304) {
|
|
22265
|
-
if (revalidationResponseDisallowsCachedReuse(globalOpts.type, headers2)) {
|
|
22266
|
-
|
|
22267
|
-
result.body.on("error", nop).destroy();
|
|
22268
|
-
}
|
|
22269
|
-
deleteCachedValue(globalOpts.store, cacheKey);
|
|
22270
|
-
return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
22505
|
+
if (!revalidationTargetMatchesCacheKey(cacheKey, context) || !revalidationEtagMatchesCachedValue(result, headers2) || revalidationResponseDisallowsCachedReuse(globalOpts.type, headers2)) {
|
|
22506
|
+
return refetch();
|
|
22271
22507
|
}
|
|
22272
22508
|
if (revalidationResponseUpdatesCacheControl(headers2)) {
|
|
22273
22509
|
deleteCachedValue(globalOpts.store, cacheKey);
|
|
22274
22510
|
} else if (revalidationResponseAddsVary(result, headers2.vary ? parseVaryHeader(headers2.vary, opts.headers) : void 0)) {
|
|
22275
|
-
|
|
22276
|
-
result.body.on("error", nop).destroy();
|
|
22277
|
-
}
|
|
22278
|
-
deleteCachedValue(globalOpts.store, cacheKey);
|
|
22279
|
-
return dispatch(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
22511
|
+
return refetch();
|
|
22280
22512
|
}
|
|
22281
22513
|
}
|
|
22282
22514
|
sendCachedValue(handler, opts, result, age, context, stale);
|
|
@@ -22374,7 +22606,31 @@ var require_cache2 = __commonJS({
|
|
|
22374
22606
|
opts2,
|
|
22375
22607
|
reqCacheControl,
|
|
22376
22608
|
result2
|
|
22377
|
-
))
|
|
22609
|
+
)).catch((err) => {
|
|
22610
|
+
if (typeof handler.onResponseError === "function") {
|
|
22611
|
+
handler.onResponseError({
|
|
22612
|
+
rawHeaders: [],
|
|
22613
|
+
rawTrailers: [],
|
|
22614
|
+
pause() {
|
|
22615
|
+
},
|
|
22616
|
+
resume() {
|
|
22617
|
+
},
|
|
22618
|
+
get paused() {
|
|
22619
|
+
return false;
|
|
22620
|
+
},
|
|
22621
|
+
get aborted() {
|
|
22622
|
+
return false;
|
|
22623
|
+
},
|
|
22624
|
+
get reason() {
|
|
22625
|
+
return null;
|
|
22626
|
+
},
|
|
22627
|
+
abort() {
|
|
22628
|
+
}
|
|
22629
|
+
}, err);
|
|
22630
|
+
} else {
|
|
22631
|
+
throw err;
|
|
22632
|
+
}
|
|
22633
|
+
});
|
|
22378
22634
|
} else {
|
|
22379
22635
|
return handleResult(
|
|
22380
22636
|
dispatch,
|
|
@@ -23382,10 +23638,15 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
23382
23638
|
var { assertCacheKey, assertCacheValue } = require_cache();
|
|
23383
23639
|
var { zstdCompressSync, zstdDecompressSync } = __require("node:zlib");
|
|
23384
23640
|
var DatabaseSync;
|
|
23385
|
-
var VERSION =
|
|
23641
|
+
var VERSION = 5;
|
|
23386
23642
|
var MAX_ENTRY_SIZE = 2 * 1e3 * 1e3 * 1e3;
|
|
23387
23643
|
var COMPRESS_THRESHOLD = 1024 * 1024;
|
|
23388
23644
|
var hasZstd = typeof zstdCompressSync === "function" && typeof zstdDecompressSync === "function";
|
|
23645
|
+
var SQLITE_BUSY = 5;
|
|
23646
|
+
var SQLITE_LOCKED = 6;
|
|
23647
|
+
function isLockedError(err) {
|
|
23648
|
+
return err?.errcode === SQLITE_BUSY || err?.errcode === SQLITE_LOCKED;
|
|
23649
|
+
}
|
|
23389
23650
|
module.exports = class SqliteCacheStore {
|
|
23390
23651
|
#maxEntrySize = MAX_ENTRY_SIZE;
|
|
23391
23652
|
#maxCount = Infinity;
|
|
@@ -23568,7 +23829,7 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
23568
23829
|
*/
|
|
23569
23830
|
get(key) {
|
|
23570
23831
|
assertCacheKey(key);
|
|
23571
|
-
const value = this.#findValue(key);
|
|
23832
|
+
const value = this.#lockSafe(() => this.#findValue(key));
|
|
23572
23833
|
return value ? {
|
|
23573
23834
|
body: value.body ? value.compressed === "zstd" ? zstdDecompressSync(Buffer.from(value.body.buffer, value.body.byteOffset, value.body.byteLength)) : Buffer.from(value.body.buffer, value.body.byteOffset, value.body.byteLength) : void 0,
|
|
23574
23835
|
statusCode: value.statusCode,
|
|
@@ -23603,9 +23864,9 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
23603
23864
|
compressed = "zstd";
|
|
23604
23865
|
}
|
|
23605
23866
|
}
|
|
23606
|
-
const existingValue = this.#findValue(key, true);
|
|
23867
|
+
const existingValue = this.#lockSafe(() => this.#findValue(key, true));
|
|
23607
23868
|
if (existingValue) {
|
|
23608
|
-
this.#updateValueQuery.run(
|
|
23869
|
+
this.#lockSafe(() => this.#updateValueQuery.run(
|
|
23609
23870
|
storedBody,
|
|
23610
23871
|
compressed,
|
|
23611
23872
|
value.deleteAt,
|
|
@@ -23618,9 +23879,9 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
23618
23879
|
value.cachedAt,
|
|
23619
23880
|
value.staleAt,
|
|
23620
23881
|
existingValue.id
|
|
23621
|
-
);
|
|
23882
|
+
));
|
|
23622
23883
|
} else {
|
|
23623
|
-
this.#insertValueQuery.run(
|
|
23884
|
+
this.#lockSafe(() => this.#insertValueQuery.run(
|
|
23624
23885
|
url2,
|
|
23625
23886
|
key.method,
|
|
23626
23887
|
storedBody,
|
|
@@ -23634,7 +23895,7 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
23634
23895
|
value.vary ? JSON.stringify(value.vary) : null,
|
|
23635
23896
|
value.cachedAt,
|
|
23636
23897
|
value.staleAt
|
|
23637
|
-
);
|
|
23898
|
+
));
|
|
23638
23899
|
this.#prune();
|
|
23639
23900
|
}
|
|
23640
23901
|
}
|
|
@@ -23673,20 +23934,46 @@ var require_sqlite_cache_store = __commonJS({
|
|
|
23673
23934
|
if (typeof key !== "object") {
|
|
23674
23935
|
throw new TypeError(`expected key to be object, got ${typeof key}`);
|
|
23675
23936
|
}
|
|
23676
|
-
this.#deleteByUrlQuery.run(this.#makeValueUrl(key));
|
|
23937
|
+
this.#lockSafe(() => this.#deleteByUrlQuery.run(this.#makeValueUrl(key)));
|
|
23938
|
+
}
|
|
23939
|
+
/**
|
|
23940
|
+
* Runs a database operation, skipping it when another connection holds the
|
|
23941
|
+
* database lock.
|
|
23942
|
+
*
|
|
23943
|
+
* The cache store is meant to be shared between processes, and SQLite reports
|
|
23944
|
+
* a concurrent writer as SQLITE_BUSY/SQLITE_LOCKED. Those errors are
|
|
23945
|
+
* transient, and caching is best effort: the entry is skipped and the next
|
|
23946
|
+
* request retries, rather than failing the request that triggered the write.
|
|
23947
|
+
*
|
|
23948
|
+
* @template T
|
|
23949
|
+
* @param {() => T} fn
|
|
23950
|
+
* @returns {T | undefined}
|
|
23951
|
+
*/
|
|
23952
|
+
#lockSafe(fn) {
|
|
23953
|
+
try {
|
|
23954
|
+
return fn();
|
|
23955
|
+
} catch (err) {
|
|
23956
|
+
if (!isLockedError(err)) {
|
|
23957
|
+
throw err;
|
|
23958
|
+
}
|
|
23959
|
+
return void 0;
|
|
23960
|
+
}
|
|
23677
23961
|
}
|
|
23678
23962
|
#prune() {
|
|
23679
|
-
if (Number.isFinite(this.#maxCount)
|
|
23680
|
-
|
|
23963
|
+
if (Number.isFinite(this.#maxCount)) {
|
|
23964
|
+
const size = this.#lockSafe(() => this.size);
|
|
23965
|
+
if (size === void 0 || size <= this.#maxCount) {
|
|
23966
|
+
return 0;
|
|
23967
|
+
}
|
|
23681
23968
|
}
|
|
23682
23969
|
{
|
|
23683
|
-
const removed = this.#deleteExpiredValuesQuery.run(Date.now()).changes;
|
|
23970
|
+
const removed = this.#lockSafe(() => this.#deleteExpiredValuesQuery.run(Date.now()).changes);
|
|
23684
23971
|
if (removed) {
|
|
23685
23972
|
return removed;
|
|
23686
23973
|
}
|
|
23687
23974
|
}
|
|
23688
23975
|
{
|
|
23689
|
-
const removed = this.#deleteOldValuesQuery?.run(Math.max(Math.floor(this.#maxCount * 0.1), 1)).changes;
|
|
23976
|
+
const removed = this.#lockSafe(() => this.#deleteOldValuesQuery?.run(Math.max(Math.floor(this.#maxCount * 0.1), 1)).changes);
|
|
23690
23977
|
if (removed) {
|
|
23691
23978
|
return removed;
|
|
23692
23979
|
}
|
|
@@ -24675,41 +24962,64 @@ var require_request2 = __commonJS({
|
|
|
24675
24962
|
var { URLSerializer } = require_data_url();
|
|
24676
24963
|
var { kConstruct } = require_symbols();
|
|
24677
24964
|
var assert2 = __require("node:assert");
|
|
24678
|
-
var {
|
|
24679
|
-
|
|
24680
|
-
var requestFinalizer = new FinalizationRegistry(({ signal, abort }) => {
|
|
24681
|
-
signal.removeEventListener("abort", abort);
|
|
24965
|
+
var requestFinalizer = new FinalizationRegistry(({ signal, reference }) => {
|
|
24966
|
+
removeSignalFollower(signal, reference);
|
|
24682
24967
|
});
|
|
24683
|
-
var
|
|
24684
|
-
var
|
|
24685
|
-
|
|
24686
|
-
|
|
24687
|
-
|
|
24688
|
-
|
|
24689
|
-
|
|
24690
|
-
|
|
24691
|
-
|
|
24692
|
-
|
|
24693
|
-
|
|
24694
|
-
|
|
24695
|
-
|
|
24696
|
-
|
|
24697
|
-
|
|
24698
|
-
|
|
24699
|
-
|
|
24700
|
-
|
|
24701
|
-
|
|
24702
|
-
|
|
24703
|
-
|
|
24704
|
-
|
|
24705
|
-
|
|
24706
|
-
|
|
24707
|
-
|
|
24708
|
-
|
|
24709
|
-
|
|
24710
|
-
|
|
24711
|
-
|
|
24968
|
+
var requestSignals = /* @__PURE__ */ new WeakMap();
|
|
24969
|
+
var signalFollowers = /* @__PURE__ */ new WeakMap();
|
|
24970
|
+
function removeSignalFollower(signal, reference) {
|
|
24971
|
+
const followers = signalFollowers.get(signal);
|
|
24972
|
+
if (followers instanceof Set) {
|
|
24973
|
+
followers.delete(reference);
|
|
24974
|
+
if (followers.size !== 0) return;
|
|
24975
|
+
}
|
|
24976
|
+
signal.removeEventListener("abort", abortSignalFollowers);
|
|
24977
|
+
signalFollowers.delete(signal);
|
|
24978
|
+
}
|
|
24979
|
+
function abortSignalFollower(reference, reason) {
|
|
24980
|
+
requestFinalizer.unregister(reference);
|
|
24981
|
+
const ac = reference.deref();
|
|
24982
|
+
if (ac !== void 0) {
|
|
24983
|
+
requestSignals.delete(ac.signal);
|
|
24984
|
+
ac.abort(reason);
|
|
24985
|
+
}
|
|
24986
|
+
}
|
|
24987
|
+
function abortSignalFollowers() {
|
|
24988
|
+
this.removeEventListener("abort", abortSignalFollowers);
|
|
24989
|
+
const followers = signalFollowers.get(this);
|
|
24990
|
+
if (followers instanceof Set) {
|
|
24991
|
+
for (const reference of followers) {
|
|
24992
|
+
abortSignalFollower(reference, this.reason);
|
|
24993
|
+
}
|
|
24994
|
+
followers.clear();
|
|
24995
|
+
} else {
|
|
24996
|
+
abortSignalFollower(followers, this.reason);
|
|
24997
|
+
}
|
|
24998
|
+
signalFollowers.delete(this);
|
|
24999
|
+
}
|
|
25000
|
+
function createDependentSignal(signal) {
|
|
25001
|
+
const ac = new AbortController();
|
|
25002
|
+
if (signal == null) return ac.signal;
|
|
25003
|
+
if (signal.aborted) {
|
|
25004
|
+
ac.abort(signal.reason);
|
|
25005
|
+
return ac.signal;
|
|
25006
|
+
}
|
|
25007
|
+
const reference = new WeakRef(ac);
|
|
25008
|
+
const followers = signalFollowers.get(signal);
|
|
25009
|
+
if (followers === void 0) {
|
|
25010
|
+
util.addAbortListener(signal, abortSignalFollowers);
|
|
25011
|
+
signalFollowers.set(signal, reference);
|
|
25012
|
+
} else if (followers instanceof WeakRef) {
|
|
25013
|
+
const controllers = /* @__PURE__ */ new Set();
|
|
25014
|
+
controllers.add(followers);
|
|
25015
|
+
controllers.add(reference);
|
|
25016
|
+
signalFollowers.set(signal, controllers);
|
|
25017
|
+
} else {
|
|
25018
|
+
followers.add(reference);
|
|
24712
25019
|
}
|
|
25020
|
+
requestFinalizer.register(ac, { signal, reference }, reference);
|
|
25021
|
+
requestSignals.set(ac.signal, { controller: ac, source: signal, reference });
|
|
25022
|
+
return ac.signal;
|
|
24713
25023
|
}
|
|
24714
25024
|
var patchMethodWarning = false;
|
|
24715
25025
|
var setRequestSignal;
|
|
@@ -24727,12 +25037,6 @@ var require_request2 = __commonJS({
|
|
|
24727
25037
|
/** @type {Headers} */
|
|
24728
25038
|
#headers;
|
|
24729
25039
|
#state;
|
|
24730
|
-
/**
|
|
24731
|
-
* Removes the `abort` listener that makes this request's signal follow the
|
|
24732
|
-
* passed signal. `null` when no such listener was registered.
|
|
24733
|
-
* @type {(() => void) | null}
|
|
24734
|
-
*/
|
|
24735
|
-
#abortCleanup = null;
|
|
24736
25040
|
// https://fetch.spec.whatwg.org/#dom-request
|
|
24737
25041
|
constructor(input2, init = void 0) {
|
|
24738
25042
|
webidl.util.markAsUncloneable(this);
|
|
@@ -24918,27 +25222,7 @@ var require_request2 = __commonJS({
|
|
|
24918
25222
|
signal = init.signal;
|
|
24919
25223
|
}
|
|
24920
25224
|
this.#state = request;
|
|
24921
|
-
|
|
24922
|
-
this.#signal = ac.signal;
|
|
24923
|
-
if (signal != null) {
|
|
24924
|
-
if (signal.aborted) {
|
|
24925
|
-
ac.abort(signal.reason);
|
|
24926
|
-
} else {
|
|
24927
|
-
this[kAbortController] = ac;
|
|
24928
|
-
const acRef = new WeakRef(ac);
|
|
24929
|
-
const abort = buildAbort(acRef);
|
|
24930
|
-
if (abortSignalHasEventHandlerLeakWarning && getMaxListeners(signal) === defaultMaxListeners) {
|
|
24931
|
-
setMaxListeners(1500, signal);
|
|
24932
|
-
}
|
|
24933
|
-
const removeAbortListener = util.addAbortListener(signal, abort);
|
|
24934
|
-
requestFinalizer.register(ac, { signal, abort }, abort);
|
|
24935
|
-
this.#abortCleanup = () => {
|
|
24936
|
-
requestFinalizer.unregister(abort);
|
|
24937
|
-
removeAbortListener();
|
|
24938
|
-
this.#abortCleanup = null;
|
|
24939
|
-
};
|
|
24940
|
-
}
|
|
24941
|
-
}
|
|
25225
|
+
this.#signal = createDependentSignal(signal);
|
|
24942
25226
|
this.#headers = new Headers(kConstruct);
|
|
24943
25227
|
setHeadersList(this.#headers, request.headersList);
|
|
24944
25228
|
setHeadersGuard(this.#headers, "request");
|
|
@@ -25132,23 +25416,8 @@ var require_request2 = __commonJS({
|
|
|
25132
25416
|
throw new TypeError("unusable");
|
|
25133
25417
|
}
|
|
25134
25418
|
const clonedRequest = cloneRequest(this.#state);
|
|
25135
|
-
const
|
|
25136
|
-
|
|
25137
|
-
ac.abort(this.signal.reason);
|
|
25138
|
-
} else {
|
|
25139
|
-
let list = dependentControllerMap.get(this.signal);
|
|
25140
|
-
if (list === void 0) {
|
|
25141
|
-
list = /* @__PURE__ */ new Set();
|
|
25142
|
-
dependentControllerMap.set(this.signal, list);
|
|
25143
|
-
}
|
|
25144
|
-
const acRef = new WeakRef(ac);
|
|
25145
|
-
list.add(acRef);
|
|
25146
|
-
util.addAbortListener(
|
|
25147
|
-
ac.signal,
|
|
25148
|
-
buildAbort(acRef)
|
|
25149
|
-
);
|
|
25150
|
-
}
|
|
25151
|
-
return fromInnerRequest(clonedRequest, this.#dispatcher, ac.signal, getHeadersGuard(this.#headers));
|
|
25419
|
+
const signal = createDependentSignal(this.#signal);
|
|
25420
|
+
return fromInnerRequest(clonedRequest, this.#dispatcher, signal, getHeadersGuard(this.#headers));
|
|
25152
25421
|
}
|
|
25153
25422
|
[nodeUtil.inspect.custom](depth, options) {
|
|
25154
25423
|
if (options.depth === null) {
|
|
@@ -25194,7 +25463,12 @@ var require_request2 = __commonJS({
|
|
|
25194
25463
|
request.#state = newState;
|
|
25195
25464
|
};
|
|
25196
25465
|
removeRequestAbortListener = (request) => {
|
|
25197
|
-
request.#
|
|
25466
|
+
const state = requestSignals.get(request.#signal);
|
|
25467
|
+
if (state !== void 0) {
|
|
25468
|
+
requestSignals.delete(request.#signal);
|
|
25469
|
+
requestFinalizer.unregister(state.reference);
|
|
25470
|
+
removeSignalFollower(state.source, state.reference);
|
|
25471
|
+
}
|
|
25198
25472
|
};
|
|
25199
25473
|
webidl.is.Request = (arg) => {
|
|
25200
25474
|
return arg != null && typeof arg === "object" && #state in arg;
|
|
@@ -25476,7 +25750,7 @@ var require_subresource_integrity = __commonJS({
|
|
|
25476
25750
|
}
|
|
25477
25751
|
function parseMetadata(metadata) {
|
|
25478
25752
|
const result = [];
|
|
25479
|
-
for (const item of metadata.split(
|
|
25753
|
+
for (const item of metadata.split(/[\t\n\f\r ]+/)) {
|
|
25480
25754
|
const expressionAndOptions = item.split("?", 1);
|
|
25481
25755
|
const algorithmExpression = expressionAndOptions[0];
|
|
25482
25756
|
let base64Value = "";
|
|
@@ -25727,11 +26001,8 @@ var require_fetch = __commonJS({
|
|
|
25727
26001
|
cleanupAbortListeners();
|
|
25728
26002
|
},
|
|
25729
26003
|
processResponse,
|
|
25730
|
-
dispatcher: getRequestDispatcher(requestObject)
|
|
26004
|
+
dispatcher: getRequestDispatcher(requestObject)
|
|
25731
26005
|
// undici
|
|
25732
|
-
// Keep requestObject alive to prevent its AbortController from being GC'd
|
|
25733
|
-
// See https://github.com/nodejs/undici/issues/4627
|
|
25734
|
-
requestObject
|
|
25735
26006
|
});
|
|
25736
26007
|
return p.promise;
|
|
25737
26008
|
}
|
|
@@ -25799,10 +26070,8 @@ var require_fetch = __commonJS({
|
|
|
25799
26070
|
processResponseEndOfBody,
|
|
25800
26071
|
processResponseConsumeBody,
|
|
25801
26072
|
useParallelQueue = false,
|
|
25802
|
-
dispatcher = getGlobalDispatcher()
|
|
26073
|
+
dispatcher = getGlobalDispatcher()
|
|
25803
26074
|
// undici
|
|
25804
|
-
requestObject = null
|
|
25805
|
-
// Keep alive to prevent AbortController GC, see #4627
|
|
25806
26075
|
}) {
|
|
25807
26076
|
assert2(dispatcher);
|
|
25808
26077
|
let taskDestination = null;
|
|
@@ -25825,9 +26094,7 @@ var require_fetch = __commonJS({
|
|
|
25825
26094
|
processResponseConsumeBody,
|
|
25826
26095
|
processResponseEndOfBody,
|
|
25827
26096
|
taskDestination,
|
|
25828
|
-
crossOriginIsolatedCapability
|
|
25829
|
-
// Keep requestObject alive to prevent its AbortController from being GC'd
|
|
25830
|
-
requestObject
|
|
26097
|
+
crossOriginIsolatedCapability
|
|
25831
26098
|
};
|
|
25832
26099
|
assert2(!request.body || request.body.stream);
|
|
25833
26100
|
if (request.window === "client") {
|