miniflare 0.0.0-e4fe35cc5 → 0.0.0-e747ddf6a
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 +34 -0
- package/dist/src/index.d.ts +425 -153
- package/dist/src/index.js +453 -237
- package/dist/src/index.js.map +3 -3
- package/dist/src/workers/assets/assets-kv.worker.js +5 -1
- package/dist/src/workers/assets/assets-kv.worker.js.map +1 -1
- package/dist/src/workers/assets/assets.worker.js +181 -29
- package/dist/src/workers/assets/assets.worker.js.map +2 -2
- package/dist/src/workers/assets/router.worker.js +82 -4
- package/dist/src/workers/assets/router.worker.js.map +2 -2
- package/dist/src/workers/cache/cache.worker.js +6 -5
- package/dist/src/workers/cache/cache.worker.js.map +2 -2
- package/dist/src/workers/core/entry.worker.js +18 -15
- package/dist/src/workers/core/entry.worker.js.map +1 -1
- package/dist/src/workers/d1/database.worker.js +1 -1
- package/dist/src/workers/d1/database.worker.js.map +1 -1
- package/dist/src/workers/queues/broker.worker.js +5 -3
- package/dist/src/workers/queues/broker.worker.js.map +1 -1
- package/dist/src/workers/workflows/binding.worker.js +1971 -0
- package/dist/src/workers/workflows/binding.worker.js.map +6 -0
- package/package.json +9 -8
|
@@ -10,7 +10,11 @@ var assets_kv_worker_default = {
|
|
|
10
10
|
if (entry === void 0)
|
|
11
11
|
return new Response("Not Found", { status: 404 });
|
|
12
12
|
let { filePath, contentType } = entry, response = await env[SharedBindings.MAYBE_SERVICE_BLOBS].fetch(
|
|
13
|
-
new URL(
|
|
13
|
+
new URL(
|
|
14
|
+
// somewhere in blobservice I think this is being decoded again
|
|
15
|
+
filePath.split("/").map((x) => encodeURIComponent(x)).join("/"),
|
|
16
|
+
"http://placeholder"
|
|
17
|
+
)
|
|
14
18
|
), newResponse = new Response(response.body, response);
|
|
15
19
|
return newResponse.headers.append(
|
|
16
20
|
"cf-kv-metadata",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/workers/assets/assets-kv.worker.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,sBAAsB;AAW/B,IAAO,2BAA8B;AAAA,EACpC,MAAM,MAAM,SAAS,KAAK;AAEzB,QAAI,QAAQ,WAAW,OAAO;AAC7B,UAAM,UAAU,UAAU,QAAQ,OAAO,YAAY;AACrD,aAAO,IAAI,SAAS,SAAS,EAAE,QAAQ,KAAK,YAAY,QAAQ,CAAC;AAAA;AAGlE,QAAM,WAAW,IAAI,IAAI,QAAQ,GAAG,EAAE,SAAS,UAAU,CAAC,GACpD,QAAQ,IAAI,mBAAmB,QAAQ;AAC7C,QAAI,UAAU;AACb,aAAO,IAAI,SAAS,aAAa,EAAE,QAAQ,IAAI,CAAC;AAGjD,QAAM,EAAE,UAAU,YAAY,IAAI,OAE5B,WAAW,MADI,IAAI,eAAe,mBAAmB,EACvB;AAAA,MACnC,IAAI,IAAI,
|
|
4
|
+
"mappings": ";AAAA,SAAS,sBAAsB;AAW/B,IAAO,2BAA8B;AAAA,EACpC,MAAM,MAAM,SAAS,KAAK;AAEzB,QAAI,QAAQ,WAAW,OAAO;AAC7B,UAAM,UAAU,UAAU,QAAQ,OAAO,YAAY;AACrD,aAAO,IAAI,SAAS,SAAS,EAAE,QAAQ,KAAK,YAAY,QAAQ,CAAC;AAAA;AAGlE,QAAM,WAAW,IAAI,IAAI,QAAQ,GAAG,EAAE,SAAS,UAAU,CAAC,GACpD,QAAQ,IAAI,mBAAmB,QAAQ;AAC7C,QAAI,UAAU;AACb,aAAO,IAAI,SAAS,aAAa,EAAE,QAAQ,IAAI,CAAC;AAGjD,QAAM,EAAE,UAAU,YAAY,IAAI,OAE5B,WAAW,MADI,IAAI,eAAe,mBAAmB,EACvB;AAAA,MACnC,IAAI;AAAA;AAAA,QAEH,SACE,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,mBAAmB,CAAC,CAAC,EAChC,KAAK,GAAG;AAAA,QACV;AAAA,MACD;AAAA,IACD,GACM,cAAc,IAAI,SAAS,SAAS,MAAM,QAAQ;AAExD,uBAAY,QAAQ;AAAA,MACnB;AAAA,MACA,oBAAoB;AAAA,IACrB,GACO;AAAA,EACR;AACD;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -8622,6 +8622,17 @@ var require_index_cjs = __commonJS({
|
|
|
8622
8622
|
// ../workers-shared/asset-worker/src/index.ts
|
|
8623
8623
|
import { WorkerEntrypoint } from "cloudflare:workers";
|
|
8624
8624
|
|
|
8625
|
+
// ../workers-shared/utils/performance.ts
|
|
8626
|
+
var PerformanceTimer = class {
|
|
8627
|
+
performanceTimer;
|
|
8628
|
+
constructor(performanceTimer) {
|
|
8629
|
+
this.performanceTimer = performanceTimer;
|
|
8630
|
+
}
|
|
8631
|
+
now() {
|
|
8632
|
+
return this.performanceTimer ? this.performanceTimer.timeOrigin + this.performanceTimer.now() : Date.now();
|
|
8633
|
+
}
|
|
8634
|
+
};
|
|
8635
|
+
|
|
8625
8636
|
// ../workers-shared/utils/sentry.ts
|
|
8626
8637
|
var import_toucan_js = __toESM(require_index_cjs());
|
|
8627
8638
|
function setupSentry(request, context, dsn, clientId, clientSecret) {
|
|
@@ -8657,6 +8668,55 @@ function setupSentry(request, context, dsn, clientId, clientSecret) {
|
|
|
8657
8668
|
return sentry.setUser({ userAgent, colo }), sentry;
|
|
8658
8669
|
}
|
|
8659
8670
|
|
|
8671
|
+
// ../workers-shared/asset-worker/src/analytics.ts
|
|
8672
|
+
var Analytics = class {
|
|
8673
|
+
data = {};
|
|
8674
|
+
readyAnalytics;
|
|
8675
|
+
constructor(readyAnalytics) {
|
|
8676
|
+
this.readyAnalytics = readyAnalytics;
|
|
8677
|
+
}
|
|
8678
|
+
setData(newData) {
|
|
8679
|
+
this.data = { ...this.data, ...newData };
|
|
8680
|
+
}
|
|
8681
|
+
getData(key) {
|
|
8682
|
+
return this.data[key];
|
|
8683
|
+
}
|
|
8684
|
+
write() {
|
|
8685
|
+
this.readyAnalytics && this.readyAnalytics.logEvent({
|
|
8686
|
+
version: 1,
|
|
8687
|
+
accountId: 0,
|
|
8688
|
+
// TODO: need to plumb through
|
|
8689
|
+
indexId: this.data.hostname?.substring(0, 96),
|
|
8690
|
+
doubles: [
|
|
8691
|
+
this.data.requestTime ?? -1,
|
|
8692
|
+
// double1
|
|
8693
|
+
this.data.coloId ?? -1,
|
|
8694
|
+
// double2
|
|
8695
|
+
this.data.metalId ?? -1,
|
|
8696
|
+
// double3
|
|
8697
|
+
this.data.coloTier ?? -1
|
|
8698
|
+
// double4
|
|
8699
|
+
],
|
|
8700
|
+
blobs: [
|
|
8701
|
+
this.data.hostname?.substring(0, 256),
|
|
8702
|
+
// blob1 - trim to 256 bytes
|
|
8703
|
+
this.data.userAgent?.substring(0, 256),
|
|
8704
|
+
// blob2 - trim to 256 bytes
|
|
8705
|
+
this.data.htmlHandling,
|
|
8706
|
+
// blob3
|
|
8707
|
+
this.data.notFoundHandling,
|
|
8708
|
+
// blob4
|
|
8709
|
+
this.data.error?.substring(0, 256),
|
|
8710
|
+
// blob5 - trim to 256 bytes
|
|
8711
|
+
this.data.version,
|
|
8712
|
+
// blob6
|
|
8713
|
+
this.data.coloRegion
|
|
8714
|
+
// blob7
|
|
8715
|
+
]
|
|
8716
|
+
});
|
|
8717
|
+
}
|
|
8718
|
+
};
|
|
8719
|
+
|
|
8660
8720
|
// ../workers-shared/asset-worker/src/assets-manifest.ts
|
|
8661
8721
|
var AssetsManifest = class {
|
|
8662
8722
|
data;
|
|
@@ -8716,7 +8776,8 @@ var AssetsManifest = class {
|
|
|
8716
8776
|
// ../workers-shared/asset-worker/src/configuration.ts
|
|
8717
8777
|
var applyConfigurationDefaults = (configuration) => ({
|
|
8718
8778
|
html_handling: configuration?.html_handling ?? "auto-trailing-slash",
|
|
8719
|
-
not_found_handling: configuration?.not_found_handling ?? "none"
|
|
8779
|
+
not_found_handling: configuration?.not_found_handling ?? "none",
|
|
8780
|
+
serve_directly: configuration?.serve_directly ?? !0
|
|
8720
8781
|
});
|
|
8721
8782
|
|
|
8722
8783
|
// ../workers-shared/asset-worker/src/responses.ts
|
|
@@ -8789,14 +8850,17 @@ function isCacheable(request) {
|
|
|
8789
8850
|
|
|
8790
8851
|
// ../workers-shared/asset-worker/src/handler.ts
|
|
8791
8852
|
var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
8792
|
-
let { pathname, search } = new URL(request.url),
|
|
8853
|
+
let { pathname, search } = new URL(request.url), decodedPathname = decodePath(pathname);
|
|
8854
|
+
decodedPathname = decodedPathname.replace(/\/+/g, "/");
|
|
8855
|
+
let intent = await getIntent(decodedPathname, configuration, exists);
|
|
8793
8856
|
if (!intent)
|
|
8794
8857
|
return new NotFoundResponse();
|
|
8795
8858
|
let method = request.method.toUpperCase();
|
|
8796
8859
|
if (!["GET", "HEAD"].includes(method))
|
|
8797
8860
|
return new MethodNotAllowedResponse();
|
|
8798
|
-
|
|
8799
|
-
|
|
8861
|
+
let decodedDestination = intent.redirect ?? decodedPathname, encodedDestination = encodePath(decodedDestination);
|
|
8862
|
+
if (encodedDestination !== pathname && intent.asset || intent.redirect)
|
|
8863
|
+
return new TemporaryRedirectResponse(encodedDestination + search);
|
|
8800
8864
|
if (!intent.asset)
|
|
8801
8865
|
return new InternalServerErrorResponse(new Error("Unknown action"));
|
|
8802
8866
|
let asset = await getByETag(intent.asset.eTag), headers = getHeaders(intent.asset.eTag, asset.contentType, request), strongETag = `"${intent.asset.eTag}"`, weakETag = `W/${strongETag}`, ifNoneMatch = request.headers.get("If-None-Match") || "";
|
|
@@ -8839,7 +8903,10 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
8839
8903
|
let redirectResult = null, eTagResult = null, exactETag = await exists(pathname);
|
|
8840
8904
|
if (pathname.endsWith("/index")) {
|
|
8841
8905
|
if (exactETag)
|
|
8842
|
-
return {
|
|
8906
|
+
return {
|
|
8907
|
+
asset: { eTag: exactETag, status: 200 },
|
|
8908
|
+
redirect: null
|
|
8909
|
+
};
|
|
8843
8910
|
if (redirectResult = await safeRedirect(
|
|
8844
8911
|
`${pathname}.html`,
|
|
8845
8912
|
pathname.slice(0, -5),
|
|
@@ -8875,7 +8942,10 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
8875
8942
|
return redirectResult;
|
|
8876
8943
|
} else if (pathname.endsWith("/")) {
|
|
8877
8944
|
if (eTagResult = await exists(`${pathname}index.html`))
|
|
8878
|
-
return {
|
|
8945
|
+
return {
|
|
8946
|
+
asset: { eTag: eTagResult, status: 200 },
|
|
8947
|
+
redirect: null
|
|
8948
|
+
};
|
|
8879
8949
|
if (redirectResult = await safeRedirect(
|
|
8880
8950
|
`${pathname.slice(0, -1)}.html`,
|
|
8881
8951
|
pathname.slice(0, -1),
|
|
@@ -8902,7 +8972,13 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
8902
8972
|
))
|
|
8903
8973
|
return redirectResult;
|
|
8904
8974
|
}
|
|
8905
|
-
return exactETag ? {
|
|
8975
|
+
return exactETag ? {
|
|
8976
|
+
asset: { eTag: exactETag, status: 200 },
|
|
8977
|
+
redirect: null
|
|
8978
|
+
} : (eTagResult = await exists(`${pathname}.html`)) ? {
|
|
8979
|
+
asset: { eTag: eTagResult, status: 200 },
|
|
8980
|
+
redirect: null
|
|
8981
|
+
} : (redirectResult = await safeRedirect(
|
|
8906
8982
|
`${pathname}/index.html`,
|
|
8907
8983
|
`${pathname}/`,
|
|
8908
8984
|
configuration,
|
|
@@ -8913,7 +8989,10 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
8913
8989
|
let redirectResult = null, eTagResult = null, exactETag = await exists(pathname);
|
|
8914
8990
|
if (pathname.endsWith("/index")) {
|
|
8915
8991
|
if (exactETag)
|
|
8916
|
-
return {
|
|
8992
|
+
return {
|
|
8993
|
+
asset: { eTag: exactETag, status: 200 },
|
|
8994
|
+
redirect: null
|
|
8995
|
+
};
|
|
8917
8996
|
if (redirectResult = await safeRedirect(
|
|
8918
8997
|
`${pathname}.html`,
|
|
8919
8998
|
pathname.slice(0, -5),
|
|
@@ -8949,9 +9028,15 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
8949
9028
|
return redirectResult;
|
|
8950
9029
|
} else if (pathname.endsWith("/")) {
|
|
8951
9030
|
if (eTagResult = await exists(`${pathname}index.html`))
|
|
8952
|
-
return {
|
|
9031
|
+
return {
|
|
9032
|
+
asset: { eTag: eTagResult, status: 200 },
|
|
9033
|
+
redirect: null
|
|
9034
|
+
};
|
|
8953
9035
|
if (eTagResult = await exists(`${pathname.slice(0, -1)}.html`))
|
|
8954
|
-
return {
|
|
9036
|
+
return {
|
|
9037
|
+
asset: { eTag: eTagResult, status: 200 },
|
|
9038
|
+
redirect: null
|
|
9039
|
+
};
|
|
8955
9040
|
} else if (pathname.endsWith(".html")) {
|
|
8956
9041
|
if (redirectResult = await safeRedirect(
|
|
8957
9042
|
pathname,
|
|
@@ -8962,7 +9047,10 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
8962
9047
|
))
|
|
8963
9048
|
return redirectResult;
|
|
8964
9049
|
if (exactETag)
|
|
8965
|
-
return {
|
|
9050
|
+
return {
|
|
9051
|
+
asset: { eTag: exactETag, status: 200 },
|
|
9052
|
+
redirect: null
|
|
9053
|
+
};
|
|
8966
9054
|
if (redirectResult = await safeRedirect(
|
|
8967
9055
|
`${pathname.slice(0, -5)}/index.html`,
|
|
8968
9056
|
`${pathname.slice(0, -5)}/`,
|
|
@@ -8972,7 +9060,10 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
8972
9060
|
))
|
|
8973
9061
|
return redirectResult;
|
|
8974
9062
|
}
|
|
8975
|
-
return exactETag ? {
|
|
9063
|
+
return exactETag ? {
|
|
9064
|
+
asset: { eTag: exactETag, status: 200 },
|
|
9065
|
+
redirect: null
|
|
9066
|
+
} : (redirectResult = await safeRedirect(
|
|
8976
9067
|
`${pathname}.html`,
|
|
8977
9068
|
`${pathname}/`,
|
|
8978
9069
|
configuration,
|
|
@@ -8989,7 +9080,10 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
8989
9080
|
let redirectResult = null, eTagResult = null, exactETag = await exists(pathname);
|
|
8990
9081
|
if (pathname.endsWith("/index")) {
|
|
8991
9082
|
if (exactETag)
|
|
8992
|
-
return {
|
|
9083
|
+
return {
|
|
9084
|
+
asset: { eTag: exactETag, status: 200 },
|
|
9085
|
+
redirect: null
|
|
9086
|
+
};
|
|
8993
9087
|
if (pathname === "/index") {
|
|
8994
9088
|
if (redirectResult = await safeRedirect(
|
|
8995
9089
|
"/index.html",
|
|
@@ -9037,7 +9131,10 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
9037
9131
|
))
|
|
9038
9132
|
return redirectResult;
|
|
9039
9133
|
if (exactETag)
|
|
9040
|
-
return {
|
|
9134
|
+
return {
|
|
9135
|
+
asset: { eTag: exactETag, status: 200 },
|
|
9136
|
+
redirect: null
|
|
9137
|
+
};
|
|
9041
9138
|
if (redirectResult = await safeRedirect(
|
|
9042
9139
|
`${pathname.slice(0, -11)}.html`,
|
|
9043
9140
|
pathname.slice(0, -11),
|
|
@@ -9050,7 +9147,10 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
9050
9147
|
else if (pathname.endsWith("/"))
|
|
9051
9148
|
if (pathname === "/") {
|
|
9052
9149
|
if (eTagResult = await exists("/index.html"))
|
|
9053
|
-
return {
|
|
9150
|
+
return {
|
|
9151
|
+
asset: { eTag: eTagResult, status: 200 },
|
|
9152
|
+
redirect: null
|
|
9153
|
+
};
|
|
9054
9154
|
} else {
|
|
9055
9155
|
if (redirectResult = await safeRedirect(
|
|
9056
9156
|
`${pathname.slice(0, -1)}.html`,
|
|
@@ -9087,15 +9187,30 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
9087
9187
|
))
|
|
9088
9188
|
return redirectResult;
|
|
9089
9189
|
}
|
|
9090
|
-
return exactETag ? {
|
|
9190
|
+
return exactETag ? {
|
|
9191
|
+
asset: { eTag: exactETag, status: 200 },
|
|
9192
|
+
redirect: null
|
|
9193
|
+
} : (eTagResult = await exists(`${pathname}.html`)) ? {
|
|
9194
|
+
asset: { eTag: eTagResult, status: 200 },
|
|
9195
|
+
redirect: null
|
|
9196
|
+
} : (eTagResult = await exists(`${pathname}/index.html`)) ? {
|
|
9197
|
+
asset: { eTag: eTagResult, status: 200 },
|
|
9198
|
+
redirect: null
|
|
9199
|
+
} : notFound(pathname, configuration, exists);
|
|
9091
9200
|
}, htmlHandlingNone = async (pathname, configuration, exists) => {
|
|
9092
9201
|
let exactETag = await exists(pathname);
|
|
9093
|
-
return exactETag ? {
|
|
9202
|
+
return exactETag ? {
|
|
9203
|
+
asset: { eTag: exactETag, status: 200 },
|
|
9204
|
+
redirect: null
|
|
9205
|
+
} : notFound(pathname, configuration, exists);
|
|
9094
9206
|
}, notFound = async (pathname, configuration, exists) => {
|
|
9095
9207
|
switch (configuration.not_found_handling) {
|
|
9096
9208
|
case "single-page-application": {
|
|
9097
9209
|
let eTag = await exists("/index.html");
|
|
9098
|
-
return eTag ? {
|
|
9210
|
+
return eTag ? {
|
|
9211
|
+
asset: { eTag, status: 200 },
|
|
9212
|
+
redirect: null
|
|
9213
|
+
} : null;
|
|
9099
9214
|
}
|
|
9100
9215
|
case "404-page": {
|
|
9101
9216
|
let cwd = pathname;
|
|
@@ -9103,7 +9218,10 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
9103
9218
|
cwd = cwd.slice(0, cwd.lastIndexOf("/"));
|
|
9104
9219
|
let eTag = await exists(`${cwd}/404.html`);
|
|
9105
9220
|
if (eTag)
|
|
9106
|
-
return {
|
|
9221
|
+
return {
|
|
9222
|
+
asset: { eTag, status: 404 },
|
|
9223
|
+
redirect: null
|
|
9224
|
+
};
|
|
9107
9225
|
}
|
|
9108
9226
|
return null;
|
|
9109
9227
|
}
|
|
@@ -9123,7 +9241,19 @@ var handleRequest = async (request, configuration, exists, getByETag) => {
|
|
|
9123
9241
|
};
|
|
9124
9242
|
}
|
|
9125
9243
|
return null;
|
|
9126
|
-
}
|
|
9244
|
+
}, decodePath = (pathname) => pathname.split("/").map((x) => {
|
|
9245
|
+
try {
|
|
9246
|
+
return decodeURIComponent(x);
|
|
9247
|
+
} catch {
|
|
9248
|
+
return x;
|
|
9249
|
+
}
|
|
9250
|
+
}).join("/"), encodePath = (pathname) => pathname.split("/").map((x) => {
|
|
9251
|
+
try {
|
|
9252
|
+
return encodeURIComponent(x);
|
|
9253
|
+
} catch {
|
|
9254
|
+
return x;
|
|
9255
|
+
}
|
|
9256
|
+
}).join("/");
|
|
9127
9257
|
|
|
9128
9258
|
// ../workers-shared/asset-worker/src/utils/kv.ts
|
|
9129
9259
|
async function getAssetWithMetadataFromKV(assetsKVNamespace, assetKey, retries = 1) {
|
|
@@ -9149,35 +9279,57 @@ async function getAssetWithMetadataFromKV(assetsKVNamespace, assetKey, retries =
|
|
|
9149
9279
|
// ../workers-shared/asset-worker/src/index.ts
|
|
9150
9280
|
var src_default = class extends WorkerEntrypoint {
|
|
9151
9281
|
async fetch(request) {
|
|
9152
|
-
let sentry;
|
|
9282
|
+
let sentry, analytics = new Analytics(this.env.ANALYTICS), performance = new PerformanceTimer(this.env.UNSAFE_PERFORMANCE), startTimeMs = performance.now();
|
|
9153
9283
|
try {
|
|
9154
|
-
|
|
9284
|
+
sentry = setupSentry(
|
|
9155
9285
|
request,
|
|
9156
9286
|
this.ctx,
|
|
9157
9287
|
this.env.SENTRY_DSN,
|
|
9158
9288
|
this.env.SENTRY_ACCESS_CLIENT_ID,
|
|
9159
9289
|
this.env.SENTRY_ACCESS_CLIENT_SECRET
|
|
9160
|
-
)
|
|
9290
|
+
);
|
|
9291
|
+
let config = applyConfigurationDefaults(this.env.CONFIG), userAgent = request.headers.get("user-agent") ?? "UA UNKNOWN";
|
|
9292
|
+
if (sentry) {
|
|
9293
|
+
let colo = this.env.COLO_METADATA.coloId;
|
|
9294
|
+
sentry.setTag("colo", this.env.COLO_METADATA.coloId), sentry.setTag("metal", this.env.COLO_METADATA.metalId), sentry.setUser({ userAgent, colo });
|
|
9295
|
+
}
|
|
9296
|
+
if (this.env.COLO_METADATA && this.env.VERSION_METADATA) {
|
|
9297
|
+
let url = new URL(request.url);
|
|
9298
|
+
analytics.setData({
|
|
9299
|
+
coloId: this.env.COLO_METADATA.coloId,
|
|
9300
|
+
metalId: this.env.COLO_METADATA.metalId,
|
|
9301
|
+
coloTier: this.env.COLO_METADATA.coloTier,
|
|
9302
|
+
coloRegion: this.env.COLO_METADATA.coloRegion,
|
|
9303
|
+
version: this.env.VERSION_METADATA.id,
|
|
9304
|
+
hostname: url.hostname,
|
|
9305
|
+
htmlHandling: config.html_handling,
|
|
9306
|
+
notFoundHandling: config.not_found_handling,
|
|
9307
|
+
userAgent
|
|
9308
|
+
});
|
|
9309
|
+
}
|
|
9310
|
+
return handleRequest(
|
|
9161
9311
|
request,
|
|
9162
|
-
|
|
9312
|
+
config,
|
|
9163
9313
|
this.unstable_exists.bind(this),
|
|
9164
9314
|
this.unstable_getByETag.bind(this)
|
|
9165
9315
|
);
|
|
9166
9316
|
} catch (err) {
|
|
9167
9317
|
let response = new InternalServerErrorResponse(err);
|
|
9168
|
-
return sentry && sentry.captureException(err), response;
|
|
9318
|
+
return sentry && sentry.captureException(err), err instanceof Error && analytics.setData({ error: err.message }), response;
|
|
9319
|
+
} finally {
|
|
9320
|
+
analytics.setData({ requestTime: performance.now() - startTimeMs }), analytics.write();
|
|
9169
9321
|
}
|
|
9170
9322
|
}
|
|
9171
9323
|
async unstable_canFetch(request) {
|
|
9172
|
-
let url = new URL(request.url),
|
|
9173
|
-
|
|
9324
|
+
let url = new URL(request.url), decodedPathname = decodePath(url.pathname);
|
|
9325
|
+
return await getIntent(
|
|
9326
|
+
decodedPathname,
|
|
9174
9327
|
{
|
|
9175
9328
|
...applyConfigurationDefaults(this.env.CONFIG),
|
|
9176
9329
|
not_found_handling: "none"
|
|
9177
9330
|
},
|
|
9178
9331
|
this.unstable_exists.bind(this)
|
|
9179
|
-
);
|
|
9180
|
-
return intent && ["GET", "HEAD"].includes(method) ? new MethodNotAllowedResponse() : intent !== null;
|
|
9332
|
+
) !== null;
|
|
9181
9333
|
}
|
|
9182
9334
|
async unstable_getByETag(eTag) {
|
|
9183
9335
|
let asset = await getAssetWithMetadataFromKV(
|