@netlify/plugin-nextjs 5.10.1 → 5.10.2
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/LICENSE +22 -0
- package/dist/esm-chunks/{package-UN6EVEHD.js → package-7HACW4PO.js} +11 -10
- package/dist/run/config.js +5 -3
- package/dist/run/handlers/cache.cjs +54 -64
- package/dist/run/handlers/request-context.cjs +10 -3
- package/dist/run/handlers/server.js +1 -2
- package/dist/run/handlers/tracer.cjs +15 -2
- package/dist/run/handlers/tracing.js +1 -1
- package/dist/run/headers.js +13 -28
- package/dist/run/next.cjs +3 -6
- package/dist/run/{regional-blob-store.cjs → storage/regional-blob-store.cjs} +7 -4
- package/dist/run/storage/request-scoped-in-memory-cache.cjs +1475 -0
- package/dist/run/storage/storage.cjs +84 -0
- package/dist/shared/blob-types.cjs +37 -0
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2023 Netlify <team@netlify.com>
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -8,7 +8,7 @@ import "./chunk-OEQOKJGE.js";
|
|
|
8
8
|
|
|
9
9
|
// package.json
|
|
10
10
|
var name = "@netlify/plugin-nextjs";
|
|
11
|
-
var version = "5.10.
|
|
11
|
+
var version = "5.10.2";
|
|
12
12
|
var description = "Run Next.js seamlessly on Netlify";
|
|
13
13
|
var main = "./dist/index.js";
|
|
14
14
|
var type = "module";
|
|
@@ -56,15 +56,15 @@ var bugs = {
|
|
|
56
56
|
};
|
|
57
57
|
var homepage = "https://opennext.js.org/netlify";
|
|
58
58
|
var devDependencies = {
|
|
59
|
-
"@fastly/http-compute-js": "1.1.
|
|
60
|
-
"@netlify/blobs": "^8.1.
|
|
61
|
-
"@netlify/build": "^
|
|
62
|
-
"@netlify/edge-bundler": "^12.
|
|
63
|
-
"@netlify/edge-functions": "^2.11.
|
|
59
|
+
"@fastly/http-compute-js": "1.1.5",
|
|
60
|
+
"@netlify/blobs": "^8.1.2",
|
|
61
|
+
"@netlify/build": "^30.1.0",
|
|
62
|
+
"@netlify/edge-bundler": "^12.4.0",
|
|
63
|
+
"@netlify/edge-functions": "^2.11.1",
|
|
64
64
|
"@netlify/eslint-config-node": "^7.0.1",
|
|
65
|
-
"@netlify/functions": "^3.0.
|
|
66
|
-
"@netlify/serverless-functions-api": "^1.
|
|
67
|
-
"@netlify/zip-it-and-ship-it": "^
|
|
65
|
+
"@netlify/functions": "^3.0.4",
|
|
66
|
+
"@netlify/serverless-functions-api": "^1.36.0",
|
|
67
|
+
"@netlify/zip-it-and-ship-it": "^10.0.4",
|
|
68
68
|
"@opentelemetry/api": "^1.8.0",
|
|
69
69
|
"@opentelemetry/exporter-trace-otlp-http": "^0.51.0",
|
|
70
70
|
"@opentelemetry/resources": "^1.24.0",
|
|
@@ -84,10 +84,11 @@ var devDependencies = {
|
|
|
84
84
|
"fs-monkey": "^1.0.6",
|
|
85
85
|
"get-port": "^7.1.0",
|
|
86
86
|
"lambda-local": "^2.2.0",
|
|
87
|
+
"lru-cache": "^10.4.3",
|
|
87
88
|
memfs: "^4.9.2",
|
|
88
89
|
"mock-require": "^3.0.3",
|
|
89
90
|
msw: "^2.0.7",
|
|
90
|
-
"netlify-cli": "^
|
|
91
|
+
"netlify-cli": "^19.1.4",
|
|
91
92
|
next: "^15.0.0-canary.28",
|
|
92
93
|
os: "^0.1.2",
|
|
93
94
|
outdent: "^0.8.0",
|
package/dist/run/config.js
CHANGED
|
@@ -11,6 +11,7 @@ import { existsSync } from "node:fs";
|
|
|
11
11
|
import { readFile } from "node:fs/promises";
|
|
12
12
|
import { join, resolve } from "node:path";
|
|
13
13
|
import { PLUGIN_DIR, RUN_CONFIG } from "./constants.js";
|
|
14
|
+
import { setInMemoryCacheMaxSizeFromNextConfig } from "./storage/storage.cjs";
|
|
14
15
|
var getRunConfig = async () => {
|
|
15
16
|
return JSON.parse(await readFile(resolve(PLUGIN_DIR, RUN_CONFIG), "utf-8"));
|
|
16
17
|
};
|
|
@@ -21,12 +22,13 @@ var setRunConfig = (config) => {
|
|
|
21
22
|
}
|
|
22
23
|
config.experimental = {
|
|
23
24
|
...config.experimental,
|
|
24
|
-
//
|
|
25
|
-
// but we still need to set it for older Next.js versions
|
|
25
|
+
// Before Next.js 14.1.0 path to the cache handler was in experimental section, see NextConfigForMultipleVersions type
|
|
26
26
|
incrementalCacheHandlerPath: cacheHandler
|
|
27
27
|
};
|
|
28
28
|
config.cacheHandler = cacheHandler;
|
|
29
|
-
|
|
29
|
+
setInMemoryCacheMaxSizeFromNextConfig(
|
|
30
|
+
config.cacheMaxMemorySize ?? config.experimental?.isrMemoryCacheSize
|
|
31
|
+
);
|
|
30
32
|
process.env.__NEXT_PRIVATE_STANDALONE_CONFIG = JSON.stringify(config);
|
|
31
33
|
};
|
|
32
34
|
export {
|
|
@@ -102,7 +102,7 @@ var init_builder = __esm({
|
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
// node_modules/@netlify/functions/dist/chunk-
|
|
105
|
+
// node_modules/@netlify/functions/dist/chunk-EZL2F32K.mjs
|
|
106
106
|
var import_process = require("process");
|
|
107
107
|
var purgeCache;
|
|
108
108
|
var init_purge_cache = __esm({
|
|
@@ -113,28 +113,37 @@ var init_purge_cache = __esm({
|
|
|
113
113
|
"`fetch` is not available. Please ensure you're using Node.js version 18.0.0 or above. Refer to https://ntl.fyi/functions-runtime for more information."
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
|
+
const { siteID } = options;
|
|
117
|
+
const { siteSlug } = options;
|
|
118
|
+
const { domain } = options;
|
|
119
|
+
if (siteID && siteSlug || siteID && domain || siteSlug && domain) {
|
|
120
|
+
throw new Error('Can only pass one of either "siteID", "siteSlug", or "domain"');
|
|
121
|
+
}
|
|
116
122
|
const payload = {
|
|
117
|
-
cache_tags: options.tags
|
|
118
|
-
deploy_alias: options.deployAlias
|
|
123
|
+
cache_tags: options.tags
|
|
119
124
|
};
|
|
125
|
+
if ("deployAlias" in options) {
|
|
126
|
+
payload.deploy_alias = options.deployAlias;
|
|
127
|
+
} else if (!import_process.env.NETLIFY_LOCAL) {
|
|
128
|
+
payload.deploy_alias = import_process.env.NETLIFY_BRANCH;
|
|
129
|
+
}
|
|
120
130
|
const token = import_process.env.NETLIFY_PURGE_API_TOKEN || options.token;
|
|
121
131
|
if (import_process.env.NETLIFY_LOCAL && !token) {
|
|
122
132
|
const scope = options.tags?.length ? ` for tags ${options.tags?.join(", ")}` : "";
|
|
123
133
|
console.log(`Skipping purgeCache${scope} in local development.`);
|
|
124
134
|
return;
|
|
125
135
|
}
|
|
126
|
-
if (
|
|
127
|
-
payload.site_slug =
|
|
128
|
-
} else if (
|
|
129
|
-
payload.domain =
|
|
136
|
+
if (siteSlug) {
|
|
137
|
+
payload.site_slug = siteSlug;
|
|
138
|
+
} else if (domain) {
|
|
139
|
+
payload.domain = domain;
|
|
130
140
|
} else {
|
|
131
|
-
|
|
132
|
-
if (!
|
|
141
|
+
payload.site_id = siteID || import_process.env.SITE_ID;
|
|
142
|
+
if (!payload.site_id) {
|
|
133
143
|
throw new Error(
|
|
134
144
|
"The Netlify site ID was not found in the execution environment. Please supply it manually using the `siteID` property."
|
|
135
145
|
);
|
|
136
146
|
}
|
|
137
|
-
payload.site_id = siteID;
|
|
138
147
|
}
|
|
139
148
|
if (!token) {
|
|
140
149
|
throw new Error(
|
|
@@ -155,7 +164,18 @@ var init_purge_cache = __esm({
|
|
|
155
164
|
body: JSON.stringify(payload)
|
|
156
165
|
});
|
|
157
166
|
if (!response.ok) {
|
|
158
|
-
|
|
167
|
+
let text;
|
|
168
|
+
try {
|
|
169
|
+
text = await response.text();
|
|
170
|
+
} catch {
|
|
171
|
+
}
|
|
172
|
+
if (text) {
|
|
173
|
+
throw new Error(`Cache purge API call was unsuccessful.
|
|
174
|
+
Status: ${response.status}
|
|
175
|
+
Body: ${text}`);
|
|
176
|
+
}
|
|
177
|
+
throw new Error(`Cache purge API call was unsuccessful.
|
|
178
|
+
Status: ${response.status}`);
|
|
159
179
|
}
|
|
160
180
|
};
|
|
161
181
|
}
|
|
@@ -175,29 +195,23 @@ var import_constants = require("next/dist/lib/constants.js");
|
|
|
175
195
|
|
|
176
196
|
// package.json
|
|
177
197
|
var name = "@netlify/plugin-nextjs";
|
|
178
|
-
var version = "5.10.
|
|
198
|
+
var version = "5.10.2";
|
|
179
199
|
|
|
180
200
|
// src/run/handlers/cache.cts
|
|
181
201
|
var import_cache_types = require("../../shared/cache-types.cjs");
|
|
182
|
-
var
|
|
202
|
+
var import_storage = require("../storage/storage.cjs");
|
|
183
203
|
var import_request_context = require("./request-context.cjs");
|
|
184
204
|
var import_tracer = require("./tracer.cjs");
|
|
185
205
|
var purgeCacheUserAgent = `${name}@${version}`;
|
|
186
206
|
var NetlifyCacheHandler = class {
|
|
187
207
|
options;
|
|
188
208
|
revalidatedTags;
|
|
189
|
-
|
|
209
|
+
cacheStore;
|
|
190
210
|
tracer = (0, import_tracer.getTracer)();
|
|
191
|
-
tagManifestsFetchedFromBlobStoreInCurrentRequest;
|
|
192
211
|
constructor(options) {
|
|
193
212
|
this.options = options;
|
|
194
213
|
this.revalidatedTags = options.revalidatedTags;
|
|
195
|
-
this.
|
|
196
|
-
this.tagManifestsFetchedFromBlobStoreInCurrentRequest = {};
|
|
197
|
-
}
|
|
198
|
-
async encodeBlobKey(key) {
|
|
199
|
-
const { encodeBlobKey } = await import("../../shared/blobkey.js");
|
|
200
|
-
return await encodeBlobKey(key);
|
|
214
|
+
this.cacheStore = (0, import_storage.getMemoizedKeyValueStoreBackedByRegionalBlobStore)({ consistency: "strong" });
|
|
201
215
|
}
|
|
202
216
|
getTTL(blob) {
|
|
203
217
|
if (blob.value?.kind === "FETCH" || blob.value?.kind === "ROUTE" || blob.value?.kind === "APP_ROUTE" || blob.value?.kind === "PAGE" || blob.value?.kind === "PAGES" || blob.value?.kind === "APP_PAGE") {
|
|
@@ -218,26 +232,17 @@ var NetlifyCacheHandler = class {
|
|
|
218
232
|
}
|
|
219
233
|
const requestContext = (0, import_request_context.getRequestContext)();
|
|
220
234
|
if (!requestContext) {
|
|
221
|
-
|
|
222
|
-
new Error("CacheHandler was called without a request context")
|
|
223
|
-
);
|
|
224
|
-
getCacheKeySpan.setAttributes({
|
|
225
|
-
severity: "alert",
|
|
226
|
-
warning: true
|
|
227
|
-
});
|
|
235
|
+
(0, import_tracer.recordWarning)(new Error("CacheHandler was called without a request context"), getCacheKeySpan);
|
|
228
236
|
return;
|
|
229
237
|
}
|
|
230
238
|
if (requestContext.responseCacheKey && requestContext.responseCacheKey !== key) {
|
|
231
239
|
requestContext.responseCacheGetLastModified = void 0;
|
|
232
|
-
|
|
240
|
+
(0, import_tracer.recordWarning)(
|
|
233
241
|
new Error(
|
|
234
242
|
`Multiple response cache keys used in single request: ["${requestContext.responseCacheKey}, "${key}"]`
|
|
235
|
-
)
|
|
243
|
+
),
|
|
244
|
+
getCacheKeySpan
|
|
236
245
|
);
|
|
237
|
-
getCacheKeySpan.setAttributes({
|
|
238
|
-
severity: "alert",
|
|
239
|
-
warning: true
|
|
240
|
-
});
|
|
241
246
|
return;
|
|
242
247
|
}
|
|
243
248
|
requestContext.responseCacheKey = key;
|
|
@@ -315,23 +320,16 @@ var NetlifyCacheHandler = class {
|
|
|
315
320
|
return this.tracer.withActiveSpan("get cache key", async (span) => {
|
|
316
321
|
const [key, ctx = {}] = args;
|
|
317
322
|
(0, import_request_context.getLogger)().debug(`[NetlifyCacheHandler.get]: ${key}`);
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const blob = await this.tracer.withActiveSpan("blobStore.get", async (blobGetSpan) => {
|
|
321
|
-
blobGetSpan.setAttributes({ key, blobKey });
|
|
322
|
-
return await this.blobStore.get(blobKey, {
|
|
323
|
-
type: "json"
|
|
324
|
-
});
|
|
325
|
-
});
|
|
323
|
+
span.setAttributes({ key });
|
|
324
|
+
const blob = await this.cacheStore.get(key, "blobStore.get");
|
|
326
325
|
if (!blob) {
|
|
327
|
-
span.addEvent("Cache miss", { key
|
|
326
|
+
span.addEvent("Cache miss", { key });
|
|
328
327
|
return null;
|
|
329
328
|
}
|
|
330
329
|
const ttl = this.getTTL(blob);
|
|
331
330
|
if ((0, import_request_context.getRequestContext)()?.isBackgroundRevalidation && typeof ttl === "number" && ttl < 0) {
|
|
332
331
|
span.addEvent("Discarding stale entry due to SWR background revalidation request", {
|
|
333
332
|
key,
|
|
334
|
-
blobKey,
|
|
335
333
|
ttl
|
|
336
334
|
});
|
|
337
335
|
(0, import_request_context.getLogger)().withFields({
|
|
@@ -344,7 +342,7 @@ var NetlifyCacheHandler = class {
|
|
|
344
342
|
}
|
|
345
343
|
const staleByTags = await this.checkCacheEntryStaleByTags(blob, ctx.tags, ctx.softTags);
|
|
346
344
|
if (staleByTags) {
|
|
347
|
-
span.addEvent("Stale", { staleByTags, key,
|
|
345
|
+
span.addEvent("Stale", { staleByTags, key, ttl });
|
|
348
346
|
return null;
|
|
349
347
|
}
|
|
350
348
|
this.captureResponseCacheLastModified(blob, key, span);
|
|
@@ -441,16 +439,12 @@ var NetlifyCacheHandler = class {
|
|
|
441
439
|
async set(...args) {
|
|
442
440
|
return this.tracer.withActiveSpan("set cache key", async (span) => {
|
|
443
441
|
const [key, data, context] = args;
|
|
444
|
-
const blobKey = await this.encodeBlobKey(key);
|
|
445
442
|
const lastModified = Date.now();
|
|
446
|
-
span.setAttributes({ key, lastModified
|
|
443
|
+
span.setAttributes({ key, lastModified });
|
|
447
444
|
(0, import_request_context.getLogger)().debug(`[NetlifyCacheHandler.set]: ${key}`);
|
|
448
445
|
const value = this.transformToStorableObject(data, context);
|
|
449
446
|
this.captureCacheTags(value, key);
|
|
450
|
-
await this.
|
|
451
|
-
lastModified,
|
|
452
|
-
value
|
|
453
|
-
});
|
|
447
|
+
await this.cacheStore.set(key, { lastModified, value }, "blobStore.set");
|
|
454
448
|
if (data?.kind === "PAGE" || data?.kind === "PAGES") {
|
|
455
449
|
const requestContext = (0, import_request_context.getRequestContext)();
|
|
456
450
|
if (requestContext?.didPagesRouterOnDemandRevalidate) {
|
|
@@ -491,7 +485,7 @@ var NetlifyCacheHandler = class {
|
|
|
491
485
|
await Promise.all(
|
|
492
486
|
tags.map(async (tag) => {
|
|
493
487
|
try {
|
|
494
|
-
await this.
|
|
488
|
+
await this.cacheStore.set(tag, data, "tagManifest.set");
|
|
495
489
|
} catch (error) {
|
|
496
490
|
(0, import_request_context.getLogger)().withError(error).log(`Failed to update tag manifest for ${tag}`);
|
|
497
491
|
}
|
|
@@ -502,7 +496,6 @@ var NetlifyCacheHandler = class {
|
|
|
502
496
|
});
|
|
503
497
|
}
|
|
504
498
|
resetRequestCache() {
|
|
505
|
-
this.tagManifestsFetchedFromBlobStoreInCurrentRequest = {};
|
|
506
499
|
}
|
|
507
500
|
/**
|
|
508
501
|
* Checks if a cache entry is stale through on demand revalidated tags
|
|
@@ -526,19 +519,16 @@ var NetlifyCacheHandler = class {
|
|
|
526
519
|
return new Promise((resolve, reject) => {
|
|
527
520
|
const tagManifestPromises = [];
|
|
528
521
|
for (const tag of cacheTags) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
span.setAttributes({ tag, blobKey });
|
|
534
|
-
return this.blobStore.get(blobKey, { type: "json" });
|
|
535
|
-
});
|
|
536
|
-
});
|
|
537
|
-
this.tagManifestsFetchedFromBlobStoreInCurrentRequest[tag] = tagManifestPromise;
|
|
538
|
-
}
|
|
522
|
+
const tagManifestPromise = this.cacheStore.get(
|
|
523
|
+
tag,
|
|
524
|
+
"tagManifest.get"
|
|
525
|
+
);
|
|
539
526
|
tagManifestPromises.push(
|
|
540
527
|
tagManifestPromise.then((tagManifest) => {
|
|
541
|
-
|
|
528
|
+
if (!tagManifest) {
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
const isStale = tagManifest.revalidatedAt >= (cacheEntry.lastModified || Date.now());
|
|
542
532
|
if (isStale) {
|
|
543
533
|
resolve(true);
|
|
544
534
|
return true;
|
|
@@ -121,6 +121,14 @@ var init_internal = __esm({
|
|
|
121
121
|
init_internal();
|
|
122
122
|
|
|
123
123
|
// src/run/handlers/request-context.cts
|
|
124
|
+
var REQUEST_CONTEXT_GLOBAL_KEY = Symbol.for("nf-request-context-async-local-storage");
|
|
125
|
+
var REQUEST_COUNTER_KEY = Symbol.for("nf-request-counter");
|
|
126
|
+
var extendedGlobalThis = globalThis;
|
|
127
|
+
function getFallbackRequestID() {
|
|
128
|
+
const requestNumber = extendedGlobalThis[REQUEST_COUNTER_KEY] ?? 0;
|
|
129
|
+
extendedGlobalThis[REQUEST_COUNTER_KEY] = requestNumber + 1;
|
|
130
|
+
return `#${requestNumber}`;
|
|
131
|
+
}
|
|
124
132
|
function createRequestContext(request, context) {
|
|
125
133
|
const backgroundWorkPromises = [];
|
|
126
134
|
const isDebugRequest = request?.headers.has("x-nf-debug-logging") || request?.headers.has("x-next-debug-logging");
|
|
@@ -142,16 +150,15 @@ function createRequestContext(request, context) {
|
|
|
142
150
|
get backgroundWorkPromise() {
|
|
143
151
|
return Promise.allSettled(backgroundWorkPromises);
|
|
144
152
|
},
|
|
145
|
-
logger
|
|
153
|
+
logger,
|
|
154
|
+
requestID: request?.headers.get("x-nf-request-id") ?? getFallbackRequestID()
|
|
146
155
|
};
|
|
147
156
|
}
|
|
148
|
-
var REQUEST_CONTEXT_GLOBAL_KEY = Symbol.for("nf-request-context-async-local-storage");
|
|
149
157
|
var requestContextAsyncLocalStorage;
|
|
150
158
|
function getRequestContextAsyncLocalStorage() {
|
|
151
159
|
if (requestContextAsyncLocalStorage) {
|
|
152
160
|
return requestContextAsyncLocalStorage;
|
|
153
161
|
}
|
|
154
|
-
const extendedGlobalThis = globalThis;
|
|
155
162
|
if (extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY]) {
|
|
156
163
|
return extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY];
|
|
157
164
|
}
|
|
@@ -3098,8 +3098,8 @@ import {
|
|
|
3098
3098
|
setCacheTagsHeaders,
|
|
3099
3099
|
setVaryHeaders
|
|
3100
3100
|
} from "../headers.js";
|
|
3101
|
-
import { setFetchBeforeNextPatchedIt } from "../regional-blob-store.cjs";
|
|
3102
3101
|
import { nextResponseProxy } from "../revalidate.js";
|
|
3102
|
+
import { setFetchBeforeNextPatchedIt } from "../storage/storage.cjs";
|
|
3103
3103
|
import { getLogger } from "./request-context.cjs";
|
|
3104
3104
|
import { getTracer } from "./tracer.cjs";
|
|
3105
3105
|
import { setupWaitUntil } from "./wait-until.cjs";
|
|
@@ -3174,7 +3174,6 @@ var server_default = async (request, _context, topLevelSpan, requestContext) =>
|
|
|
3174
3174
|
headers: response.headers,
|
|
3175
3175
|
request,
|
|
3176
3176
|
span,
|
|
3177
|
-
tracer,
|
|
3178
3177
|
requestContext
|
|
3179
3178
|
});
|
|
3180
3179
|
}
|
|
@@ -20,7 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/run/handlers/tracer.cts
|
|
21
21
|
var tracer_exports = {};
|
|
22
22
|
__export(tracer_exports, {
|
|
23
|
-
getTracer: () => getTracer
|
|
23
|
+
getTracer: () => getTracer,
|
|
24
|
+
recordWarning: () => recordWarning
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(tracer_exports);
|
|
26
27
|
|
|
@@ -897,7 +898,19 @@ function getTracer() {
|
|
|
897
898
|
}
|
|
898
899
|
return tracer;
|
|
899
900
|
}
|
|
901
|
+
function recordWarning(warning, span) {
|
|
902
|
+
const spanToRecordWarningOn = span ?? trace.getActiveSpan();
|
|
903
|
+
if (!spanToRecordWarningOn) {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
spanToRecordWarningOn.recordException(warning);
|
|
907
|
+
spanToRecordWarningOn.setAttributes({
|
|
908
|
+
severity: "alert",
|
|
909
|
+
warning: true
|
|
910
|
+
});
|
|
911
|
+
}
|
|
900
912
|
// Annotate the CommonJS export names for ESM import in node:
|
|
901
913
|
0 && (module.exports = {
|
|
902
|
-
getTracer
|
|
914
|
+
getTracer,
|
|
915
|
+
recordWarning
|
|
903
916
|
});
|
|
@@ -68866,7 +68866,7 @@ var import_semantic_conventions = __toESM(require_src(), 1);
|
|
|
68866
68866
|
import { getLogger } from "./request-context.cjs";
|
|
68867
68867
|
var {
|
|
68868
68868
|
default: { version, name }
|
|
68869
|
-
} = await import("../../esm-chunks/package-
|
|
68869
|
+
} = await import("../../esm-chunks/package-7HACW4PO.js");
|
|
68870
68870
|
var sdk = new import_sdk_node.NodeSDK({
|
|
68871
68871
|
resource: new import_resources.Resource({
|
|
68872
68872
|
[import_semantic_conventions.SEMRESATTRS_SERVICE_NAME]: name,
|
package/dist/run/headers.js
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
import "../esm-chunks/chunk-OEQOKJGE.js";
|
|
8
8
|
|
|
9
9
|
// src/run/headers.ts
|
|
10
|
-
import { encodeBlobKey } from "../shared/blobkey.js";
|
|
11
10
|
import { getLogger } from "./handlers/request-context.cjs";
|
|
12
|
-
import {
|
|
11
|
+
import { recordWarning } from "./handlers/tracer.cjs";
|
|
12
|
+
import { getMemoizedKeyValueStoreBackedByRegionalBlobStore } from "./storage/storage.cjs";
|
|
13
13
|
var ALL_VARIATIONS = Symbol.for("ALL_VARIATIONS");
|
|
14
14
|
var NetlifyVaryKeys = /* @__PURE__ */ new Set(["header", "language", "cookie", "query", "country"]);
|
|
15
15
|
var isNetlifyVaryKey = (key) => NetlifyVaryKeys.has(key);
|
|
@@ -88,7 +88,6 @@ var adjustDateHeader = async ({
|
|
|
88
88
|
headers,
|
|
89
89
|
request,
|
|
90
90
|
span,
|
|
91
|
-
tracer,
|
|
92
91
|
requestContext
|
|
93
92
|
}) => {
|
|
94
93
|
const key = new URL(request.url).pathname;
|
|
@@ -96,38 +95,24 @@ var adjustDateHeader = async ({
|
|
|
96
95
|
if (requestContext.responseCacheGetLastModified) {
|
|
97
96
|
lastModified = requestContext.responseCacheGetLastModified;
|
|
98
97
|
} else {
|
|
99
|
-
|
|
100
|
-
new Error("lastModified not found in requestContext, falling back to trying blobs")
|
|
98
|
+
recordWarning(
|
|
99
|
+
new Error("lastModified not found in requestContext, falling back to trying blobs"),
|
|
100
|
+
span
|
|
101
101
|
);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const blobStore = getRegionalBlobStore({ consistency: "strong" });
|
|
107
|
-
const blobKey = await encodeBlobKey(key);
|
|
108
|
-
lastModified = await tracer.withActiveSpan(
|
|
109
|
-
"get cache to calculate date header",
|
|
110
|
-
async (getBlobForDateSpan) => {
|
|
111
|
-
getBlobForDateSpan.setAttributes({
|
|
112
|
-
key,
|
|
113
|
-
blobKey
|
|
114
|
-
});
|
|
115
|
-
const blob = await blobStore.get(blobKey, { type: "json" }) ?? {};
|
|
116
|
-
getBlobForDateSpan.addEvent(blob ? "Cache hit" : "Cache miss");
|
|
117
|
-
return blob.lastModified;
|
|
118
|
-
}
|
|
102
|
+
const cacheStore = getMemoizedKeyValueStoreBackedByRegionalBlobStore({ consistency: "strong" });
|
|
103
|
+
const cacheEntry = await cacheStore.get(
|
|
104
|
+
key,
|
|
105
|
+
"get cache to calculate date header"
|
|
119
106
|
);
|
|
107
|
+
lastModified = cacheEntry?.lastModified;
|
|
120
108
|
}
|
|
121
109
|
if (!lastModified) {
|
|
122
|
-
|
|
110
|
+
recordWarning(
|
|
123
111
|
new Error(
|
|
124
112
|
"lastModified not found in either requestContext or blobs, date header for cached response is not set"
|
|
125
|
-
)
|
|
113
|
+
),
|
|
114
|
+
span
|
|
126
115
|
);
|
|
127
|
-
span.setAttributes({
|
|
128
|
-
severity: "alert",
|
|
129
|
-
warning: true
|
|
130
|
-
});
|
|
131
116
|
return;
|
|
132
117
|
}
|
|
133
118
|
const lastModifiedDate = new Date(lastModified);
|
package/dist/run/next.cjs
CHANGED
|
@@ -493,7 +493,7 @@ var import_path = require("path");
|
|
|
493
493
|
var import_fs_monkey = __toESM(require_lib());
|
|
494
494
|
var import_request_context = require("./handlers/request-context.cjs");
|
|
495
495
|
var import_tracer = require("./handlers/tracer.cjs");
|
|
496
|
-
var
|
|
496
|
+
var import_storage = require("./storage/storage.cjs");
|
|
497
497
|
process.env.NODE_ENV = "production";
|
|
498
498
|
var { getRequestHandlers } = require("next/dist/server/lib/start-server.js");
|
|
499
499
|
var ResponseCache = require("next/dist/server/response-cache/index.js").default;
|
|
@@ -543,18 +543,15 @@ async function getMockedRequestHandler(...args) {
|
|
|
543
543
|
const tracer = (0, import_tracer.getTracer)();
|
|
544
544
|
return tracer.withActiveSpan("mocked request handler", async () => {
|
|
545
545
|
const ofs = { ...import_promises.default };
|
|
546
|
-
const { encodeBlobKey } = await import("../shared/blobkey.js");
|
|
547
546
|
async function readFileFallbackBlobStore(...fsargs) {
|
|
548
547
|
const [path, options] = fsargs;
|
|
549
548
|
try {
|
|
550
549
|
return await ofs.readFile(path, options);
|
|
551
550
|
} catch (error) {
|
|
552
551
|
if (typeof path === "string" && path.endsWith(".html")) {
|
|
553
|
-
const
|
|
552
|
+
const cacheStore = (0, import_storage.getMemoizedKeyValueStoreBackedByRegionalBlobStore)();
|
|
554
553
|
const relPath = (0, import_path.relative)((0, import_path.resolve)(".next/server/pages"), path);
|
|
555
|
-
const file = await
|
|
556
|
-
type: "json"
|
|
557
|
-
});
|
|
554
|
+
const file = await cacheStore.get(relPath, "staticHtml.get");
|
|
558
555
|
if (file !== null) {
|
|
559
556
|
if (!file.isFallback) {
|
|
560
557
|
const requestContext = (0, import_request_context.getRequestContext)();
|
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/run/regional-blob-store.cts
|
|
20
|
+
// src/run/storage/regional-blob-store.cts
|
|
21
21
|
var regional_blob_store_exports = {};
|
|
22
22
|
__export(regional_blob_store_exports, {
|
|
23
23
|
getRegionalBlobStore: () => getRegionalBlobStore,
|
|
@@ -25,7 +25,7 @@ __export(regional_blob_store_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(regional_blob_store_exports);
|
|
27
27
|
|
|
28
|
-
// node_modules/@netlify/blobs/dist/chunk-
|
|
28
|
+
// node_modules/@netlify/blobs/dist/chunk-XR3MUBBK.js
|
|
29
29
|
var NF_ERROR = "x-nf-error";
|
|
30
30
|
var NF_REQUEST_ID = "x-nf-request-id";
|
|
31
31
|
var BlobsInternalError = class extends Error {
|
|
@@ -143,7 +143,10 @@ var BlobsConsistencyError = class extends Error {
|
|
|
143
143
|
var REGION_AUTO = "auto";
|
|
144
144
|
var regions = {
|
|
145
145
|
"us-east-1": true,
|
|
146
|
-
"us-east-2": true
|
|
146
|
+
"us-east-2": true,
|
|
147
|
+
"eu-central-1": true,
|
|
148
|
+
"ap-southeast-1": true,
|
|
149
|
+
"ap-southeast-2": true
|
|
147
150
|
};
|
|
148
151
|
var isValidRegion = (input) => Object.keys(regions).includes(input);
|
|
149
152
|
var InvalidBlobsRegionError = class extends Error {
|
|
@@ -614,7 +617,7 @@ var getDeployStore = (input = {}) => {
|
|
|
614
617
|
return new Store({ client, deployID, name: options.name });
|
|
615
618
|
};
|
|
616
619
|
|
|
617
|
-
// src/run/regional-blob-store.cts
|
|
620
|
+
// src/run/storage/regional-blob-store.cts
|
|
618
621
|
var FETCH_BEFORE_NEXT_PATCHED_IT = Symbol.for("nf-not-patched-fetch");
|
|
619
622
|
var extendedGlobalThis = globalThis;
|
|
620
623
|
function attemptToGetOriginalFetch(fetch) {
|