@netlify/plugin-nextjs 5.10.7 → 5.11.1

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.
Files changed (34) hide show
  1. package/dist/build/advanced-api-routes.js +1 -1
  2. package/dist/build/cache.js +1 -1
  3. package/dist/build/content/prerendered.js +47 -21
  4. package/dist/build/content/server.js +22 -15
  5. package/dist/build/content/static.js +4 -8
  6. package/dist/build/functions/edge.js +2 -2
  7. package/dist/build/functions/server.js +4 -8
  8. package/dist/build/image-cdn.js +1 -1
  9. package/dist/build/plugin-context.js +2 -2
  10. package/dist/build/templates/handler-monorepo.tmpl.js +0 -5
  11. package/dist/build/templates/handler.tmpl.js +0 -4
  12. package/dist/build/verification.js +3 -3
  13. package/dist/esm-chunks/{chunk-OEQOKJGE.js → chunk-6BT4RYQJ.js} +1 -12
  14. package/dist/esm-chunks/{chunk-APO262HE.js → chunk-F7NTXMLE.js} +26 -10
  15. package/dist/esm-chunks/chunk-FKDTZJRV.js +832 -0
  16. package/dist/esm-chunks/{chunk-NFOLXH6F.js → chunk-YUXQHOYO.js} +1 -1
  17. package/dist/index.js +3 -7
  18. package/dist/run/config.js +3 -3
  19. package/dist/run/constants.js +3 -3
  20. package/dist/run/handlers/cache.cjs +24 -234
  21. package/dist/run/handlers/request-context.cjs +63 -88
  22. package/dist/run/handlers/server.js +9 -6
  23. package/dist/run/handlers/tags-handler.cjs +192 -0
  24. package/dist/run/handlers/tracer.cjs +4 -4
  25. package/dist/run/handlers/use-cache-handler.js +1553 -0
  26. package/dist/run/headers.js +1 -1
  27. package/dist/run/revalidate.js +1 -1
  28. package/dist/shared/blobkey.js +1 -1
  29. package/edge-runtime/lib/routing.ts +12 -2
  30. package/package.json +1 -1
  31. package/dist/esm-chunks/chunk-5QSXBV7L.js +0 -89
  32. package/dist/esm-chunks/chunk-GNGHTHMQ.js +0 -1624
  33. package/dist/esm-chunks/package-SGSU42JZ.js +0 -148
  34. package/dist/run/handlers/tracing.js +0 -68968
@@ -7,7 +7,7 @@
7
7
  import {
8
8
  __commonJS,
9
9
  __require
10
- } from "./chunk-OEQOKJGE.js";
10
+ } from "./chunk-6BT4RYQJ.js";
11
11
 
12
12
  // node_modules/fast-glob/out/utils/array.js
13
13
  var require_array = __commonJS({
package/dist/index.js CHANGED
@@ -5,16 +5,12 @@
5
5
  })();
6
6
 
7
7
  import {
8
+ trace,
8
9
  wrapTracer
9
- } from "./esm-chunks/chunk-5QSXBV7L.js";
10
- import {
11
- init_esm,
12
- trace
13
- } from "./esm-chunks/chunk-GNGHTHMQ.js";
14
- import "./esm-chunks/chunk-OEQOKJGE.js";
10
+ } from "./esm-chunks/chunk-FKDTZJRV.js";
11
+ import "./esm-chunks/chunk-6BT4RYQJ.js";
15
12
 
16
13
  // src/index.ts
17
- init_esm();
18
14
  import { rm } from "fs/promises";
19
15
  import { restoreBuildCache, saveBuildCache } from "./build/cache.js";
20
16
  import { copyPrerenderedContent } from "./build/content/prerendered.js";
@@ -4,16 +4,16 @@
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
- import "../esm-chunks/chunk-OEQOKJGE.js";
7
+ import "../esm-chunks/chunk-6BT4RYQJ.js";
8
8
 
9
9
  // src/run/config.ts
10
10
  import { existsSync } from "node:fs";
11
11
  import { readFile } from "node:fs/promises";
12
12
  import { join, resolve } from "node:path";
13
- import { PLUGIN_DIR, RUN_CONFIG } from "./constants.js";
13
+ import { PLUGIN_DIR, RUN_CONFIG_FILE } from "./constants.js";
14
14
  import { setInMemoryCacheMaxSizeFromNextConfig } from "./storage/storage.cjs";
15
15
  var getRunConfig = async () => {
16
- return JSON.parse(await readFile(resolve(PLUGIN_DIR, RUN_CONFIG), "utf-8"));
16
+ return JSON.parse(await readFile(resolve(PLUGIN_DIR, RUN_CONFIG_FILE), "utf-8"));
17
17
  };
18
18
  var setRunConfig = (config) => {
19
19
  const cacheHandler = join(PLUGIN_DIR, ".netlify/dist/run/handlers/cache.cjs");
@@ -4,16 +4,16 @@
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
- import "../esm-chunks/chunk-OEQOKJGE.js";
7
+ import "../esm-chunks/chunk-6BT4RYQJ.js";
8
8
 
9
9
  // src/run/constants.ts
10
10
  import { resolve } from "node:path";
11
11
  import { fileURLToPath } from "node:url";
12
12
  var MODULE_DIR = fileURLToPath(new URL(".", import.meta.url));
13
13
  var PLUGIN_DIR = resolve(`${MODULE_DIR}../../..`);
14
- var RUN_CONFIG = "run-config.json";
14
+ var RUN_CONFIG_FILE = "run-config.json";
15
15
  export {
16
16
  MODULE_DIR,
17
17
  PLUGIN_DIR,
18
- RUN_CONFIG
18
+ RUN_CONFIG_FILE
19
19
  };
@@ -6,8 +6,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __export = (target, all) => {
9
- for (var name2 in all)
10
- __defProp(target, name2, { get: all[name2], enumerable: true });
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
11
  };
12
12
  var __copyProps = (to, from, except, desc) => {
13
13
  if (from && typeof from === "object" || typeof from === "function") {
@@ -37,172 +37,13 @@ module.exports = __toCommonJS(cache_exports);
37
37
  var import_node_buffer = require("node:buffer");
38
38
  var import_node_path = require("node:path");
39
39
  var import_posix = require("node:path/posix");
40
-
41
- // node_modules/@netlify/functions/dist/chunk-C6P2IO65.mjs
42
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
43
- var __esm = (fn, res) => function __init() {
44
- return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
45
- };
46
-
47
- // node_modules/@netlify/functions/dist/chunk-7VFCQORF.mjs
48
- var BUILDER_FUNCTIONS_FLAG;
49
- var HTTP_STATUS_METHOD_NOT_ALLOWED;
50
- var HTTP_STATUS_OK;
51
- var METADATA_VERSION;
52
- var init_consts = __esm({
53
- "src/lib/consts.ts"() {
54
- BUILDER_FUNCTIONS_FLAG = true;
55
- HTTP_STATUS_METHOD_NOT_ALLOWED = 405;
56
- HTTP_STATUS_OK = 200;
57
- METADATA_VERSION = 1;
58
- }
59
- });
60
-
61
- // node_modules/@netlify/functions/dist/chunk-6V4VUZWK.mjs
62
- var augmentResponse;
63
- var wrapHandler;
64
- var init_builder = __esm({
65
- "src/lib/builder.ts"() {
66
- init_consts();
67
- augmentResponse = (response) => {
68
- if (!response) {
69
- return response;
70
- }
71
- const metadata = { version: METADATA_VERSION, builder_function: BUILDER_FUNCTIONS_FLAG, ttl: response.ttl || 0 };
72
- return {
73
- ...response,
74
- metadata
75
- };
76
- };
77
- wrapHandler = (handler) => (
78
- // eslint-disable-next-line promise/prefer-await-to-callbacks
79
- (event, context, callback) => {
80
- if (event.httpMethod !== "GET" && event.httpMethod !== "HEAD") {
81
- return Promise.resolve({
82
- body: "Method Not Allowed",
83
- statusCode: HTTP_STATUS_METHOD_NOT_ALLOWED
84
- });
85
- }
86
- const modifiedEvent = {
87
- ...event,
88
- multiValueQueryStringParameters: {},
89
- queryStringParameters: {}
90
- };
91
- const wrappedCallback = (error, response) => (
92
- // eslint-disable-next-line promise/prefer-await-to-callbacks
93
- callback ? callback(error, augmentResponse(response)) : null
94
- );
95
- const execution = handler(modifiedEvent, context, wrappedCallback);
96
- if (typeof execution === "object" && typeof execution.then === "function") {
97
- return execution.then(augmentResponse);
98
- }
99
- return execution;
100
- }
101
- );
102
- }
103
- });
104
-
105
- // node_modules/@netlify/functions/dist/chunk-EZL2F32K.mjs
106
- var import_process = require("process");
107
- var purgeCache;
108
- var init_purge_cache = __esm({
109
- "src/lib/purge_cache.ts"() {
110
- purgeCache = async (options = {}) => {
111
- if (globalThis.fetch === void 0) {
112
- throw new Error(
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
- );
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
- }
122
- const payload = {
123
- cache_tags: options.tags
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
- }
130
- const token = import_process.env.NETLIFY_PURGE_API_TOKEN || options.token;
131
- if (import_process.env.NETLIFY_LOCAL && !token) {
132
- const scope = options.tags?.length ? ` for tags ${options.tags?.join(", ")}` : "";
133
- console.log(`Skipping purgeCache${scope} in local development.`);
134
- return;
135
- }
136
- if (siteSlug) {
137
- payload.site_slug = siteSlug;
138
- } else if (domain) {
139
- payload.domain = domain;
140
- } else {
141
- payload.site_id = siteID || import_process.env.SITE_ID;
142
- if (!payload.site_id) {
143
- throw new Error(
144
- "The Netlify site ID was not found in the execution environment. Please supply it manually using the `siteID` property."
145
- );
146
- }
147
- }
148
- if (!token) {
149
- throw new Error(
150
- "The cache purge API token was not found in the execution environment. Please supply it manually using the `token` property."
151
- );
152
- }
153
- const headers = {
154
- "Content-Type": "application/json; charset=utf8",
155
- Authorization: `Bearer ${token}`
156
- };
157
- if (options.userAgent) {
158
- headers["user-agent"] = options.userAgent;
159
- }
160
- const apiURL = options.apiURL || "https://api.netlify.com";
161
- const response = await fetch(`${apiURL}/api/v1/purge`, {
162
- method: "POST",
163
- headers,
164
- body: JSON.stringify(payload)
165
- });
166
- if (!response.ok) {
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}`);
179
- }
180
- };
181
- }
182
- });
183
-
184
- // node_modules/@netlify/functions/dist/chunk-MMCOWF6U.mjs
185
- var import_node_stream = require("node:stream");
186
- var import_node_util = require("node:util");
187
- var pipeline = (0, import_node_util.promisify)(import_node_stream.pipeline);
188
-
189
- // node_modules/@netlify/functions/dist/main.mjs
190
- init_builder();
191
- init_purge_cache();
192
-
193
- // src/run/handlers/cache.cts
194
40
  var import_constants = require("next/dist/lib/constants.js");
195
-
196
- // package.json
197
- var name = "@netlify/plugin-nextjs";
198
- var version = "5.10.7";
199
-
200
- // src/run/handlers/cache.cts
201
41
  var import_cache_types = require("../../shared/cache-types.cjs");
202
42
  var import_storage = require("../storage/storage.cjs");
203
43
  var import_request_context = require("./request-context.cjs");
44
+ var import_tags_handler = require("./tags-handler.cjs");
204
45
  var import_tracer = require("./tracer.cjs");
205
- var purgeCacheUserAgent = `${name}@${version}`;
46
+ var memoizedPrerenderManifest;
206
47
  var NetlifyCacheHandler = class {
207
48
  options;
208
49
  revalidatedTags;
@@ -281,13 +122,24 @@ var NetlifyCacheHandler = class {
281
122
  }
282
123
  }
283
124
  }
125
+ async getPrerenderManifest(serverDistDir) {
126
+ if (memoizedPrerenderManifest) {
127
+ return memoizedPrerenderManifest;
128
+ }
129
+ const prerenderManifestPath = (0, import_node_path.join)(serverDistDir, "..", "prerender-manifest.json");
130
+ try {
131
+ const { loadManifest } = await import("next/dist/server/load-manifest.external.js");
132
+ memoizedPrerenderManifest = loadManifest(prerenderManifestPath);
133
+ } catch {
134
+ const { loadManifest } = await import("next/dist/server/load-manifest.js");
135
+ memoizedPrerenderManifest = loadManifest(prerenderManifestPath);
136
+ }
137
+ return memoizedPrerenderManifest;
138
+ }
284
139
  async injectEntryToPrerenderManifest(key, { revalidate, cacheControl }) {
285
140
  if (this.options.serverDistDir && (typeof revalidate === "number" || revalidate === false || typeof cacheControl !== "undefined")) {
286
141
  try {
287
- const { loadManifest } = await import("next/dist/server/load-manifest.js");
288
- const prerenderManifest = loadManifest(
289
- (0, import_node_path.join)(this.options.serverDistDir, "..", "prerender-manifest.json")
290
- );
142
+ const prerenderManifest = await this.getPrerenderManifest(this.options.serverDistDir);
291
143
  if (typeof cacheControl !== "undefined") {
292
144
  const { SharedCacheControls } = await import(
293
145
  // @ts-expect-error supporting multiple next version, this module is not resolvable with currently used dev dependency
@@ -471,58 +323,20 @@ var NetlifyCacheHandler = class {
471
323
  const requestContext = (0, import_request_context.getRequestContext)();
472
324
  if (requestContext?.didPagesRouterOnDemandRevalidate) {
473
325
  const tag = `_N_T_${key === "/index" ? "/" : encodeURI(key)}`;
474
- const tags = tag.split(/,|%2c/gi).filter(Boolean);
475
- if (tags.length === 0) {
476
- return;
477
- }
478
- (0, import_request_context.getLogger)().debug(`Purging CDN cache for: [${tag}]`);
479
- requestContext.trackBackgroundWork(
480
- purgeCache({ tags, userAgent: purgeCacheUserAgent }).catch((error) => {
481
- (0, import_request_context.getLogger)().withError(error).error(`[NetlifyCacheHandler]: Purging the cache for tag ${tag} failed`);
482
- })
483
- );
326
+ requestContext?.trackBackgroundWork((0, import_tags_handler.purgeEdgeCache)(tag));
484
327
  }
485
328
  }
486
329
  });
487
330
  }
488
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
489
- async revalidateTag(tagOrTags, ...args) {
490
- const revalidateTagPromise = this.doRevalidateTag(tagOrTags, ...args);
491
- const requestContext = (0, import_request_context.getRequestContext)();
492
- if (requestContext) {
493
- requestContext.trackBackgroundWork(revalidateTagPromise);
494
- }
495
- return revalidateTagPromise;
496
- }
497
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
498
- async doRevalidateTag(tagOrTags, ...args) {
499
- (0, import_request_context.getLogger)().withFields({ tagOrTags, args }).debug("NetlifyCacheHandler.revalidateTag");
500
- const tags = (Array.isArray(tagOrTags) ? tagOrTags : [tagOrTags]).flatMap((tag) => tag.split(/,|%2c/gi)).filter(Boolean);
501
- if (tags.length === 0) {
502
- return;
503
- }
504
- const data = {
505
- revalidatedAt: Date.now()
506
- };
507
- await Promise.all(
508
- tags.map(async (tag) => {
509
- try {
510
- await this.cacheStore.set(tag, data, "tagManifest.set");
511
- } catch (error) {
512
- (0, import_request_context.getLogger)().withError(error).log(`Failed to update tag manifest for ${tag}`);
513
- }
514
- })
515
- );
516
- await purgeCache({ tags, userAgent: purgeCacheUserAgent }).catch((error) => {
517
- (0, import_request_context.getLogger)().withError(error).error(`[NetlifyCacheHandler]: Purging the cache for tags ${tags.join(", ")} failed`);
518
- });
331
+ async revalidateTag(tagOrTags) {
332
+ return (0, import_tags_handler.markTagsAsStaleAndPurgeEdgeCache)(tagOrTags);
519
333
  }
520
334
  resetRequestCache() {
521
335
  }
522
336
  /**
523
337
  * Checks if a cache entry is stale through on demand revalidated tags
524
338
  */
525
- async checkCacheEntryStaleByTags(cacheEntry, tags = [], softTags = []) {
339
+ checkCacheEntryStaleByTags(cacheEntry, tags = [], softTags = []) {
526
340
  let cacheTags = [];
527
341
  if (cacheEntry.value?.kind === "FETCH") {
528
342
  cacheTags = [...tags, ...softTags];
@@ -538,31 +352,7 @@ var NetlifyCacheHandler = class {
538
352
  }
539
353
  }
540
354
  }
541
- return new Promise((resolve, reject) => {
542
- const tagManifestPromises = [];
543
- for (const tag of cacheTags) {
544
- const tagManifestPromise = this.cacheStore.get(
545
- tag,
546
- "tagManifest.get"
547
- );
548
- tagManifestPromises.push(
549
- tagManifestPromise.then((tagManifest) => {
550
- if (!tagManifest) {
551
- return false;
552
- }
553
- const isStale = tagManifest.revalidatedAt >= (cacheEntry.lastModified || Date.now());
554
- if (isStale) {
555
- resolve(true);
556
- return true;
557
- }
558
- return false;
559
- })
560
- );
561
- }
562
- Promise.all(tagManifestPromises).then((tagManifestAreStale) => {
563
- resolve(tagManifestAreStale.some((tagIsStale) => tagIsStale));
564
- }).catch(reject);
565
- });
355
+ return (0, import_tags_handler.isAnyTagStale)(cacheTags, cacheEntry.lastModified);
566
356
  }
567
357
  };
568
358
  var cache_default = NetlifyCacheHandler;
@@ -28,97 +28,72 @@ __export(request_context_exports, {
28
28
  module.exports = __toCommonJS(request_context_exports);
29
29
  var import_node_async_hooks = require("node:async_hooks");
30
30
 
31
- // node_modules/@netlify/functions/dist/chunk-C6P2IO65.mjs
32
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
33
- var __esm = (fn, res) => function __init() {
34
- return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
35
- };
36
-
37
- // node_modules/@netlify/functions/dist/chunk-ATZ7N7EG.mjs
31
+ // node_modules/@netlify/functions/dist/internal.js
38
32
  var import_process = require("process");
39
- var systemLogTag;
40
- var serializeError;
41
- var LogLevel;
42
- var SystemLogger;
43
- var systemLogger;
44
- var init_system_logger = __esm({
45
- "src/lib/system_logger.ts"() {
46
- systemLogTag = "__nfSystemLog";
47
- serializeError = (error) => {
48
- const cause = error?.cause instanceof Error ? serializeError(error.cause) : error.cause;
49
- return {
50
- error: error.message,
51
- error_cause: cause,
52
- error_stack: error.stack
53
- };
54
- };
55
- LogLevel = /* @__PURE__ */ ((LogLevel2) => {
56
- LogLevel2[LogLevel2["Debug"] = 1] = "Debug";
57
- LogLevel2[LogLevel2["Log"] = 2] = "Log";
58
- LogLevel2[LogLevel2["Error"] = 3] = "Error";
59
- return LogLevel2;
60
- })(LogLevel || {});
61
- SystemLogger = class _SystemLogger {
62
- fields;
63
- logLevel;
64
- constructor(fields = {}, logLevel = 2) {
65
- this.fields = fields;
66
- this.logLevel = logLevel;
67
- }
68
- doLog(logger, message) {
69
- if (import_process.env.NETLIFY_DEV && !import_process.env.NETLIFY_ENABLE_SYSTEM_LOGGING) {
70
- return;
71
- }
72
- logger(systemLogTag, JSON.stringify({ msg: message, fields: this.fields }));
73
- }
74
- log(message) {
75
- if (this.logLevel > 2) {
76
- return;
77
- }
78
- this.doLog(console.log, message);
79
- }
80
- debug(message) {
81
- if (this.logLevel > 1) {
82
- return;
83
- }
84
- this.doLog(console.debug, message);
85
- }
86
- error(message) {
87
- if (this.logLevel > 3) {
88
- return;
89
- }
90
- this.doLog(console.error, message);
91
- }
92
- withLogLevel(level) {
93
- return new _SystemLogger(this.fields, level);
94
- }
95
- withFields(fields) {
96
- return new _SystemLogger(
97
- {
98
- ...this.fields,
99
- ...fields
100
- },
101
- this.logLevel
102
- );
103
- }
104
- withError(error) {
105
- const fields = error instanceof Error ? serializeError(error) : { error };
106
- return this.withFields(fields);
107
- }
108
- };
109
- systemLogger = new SystemLogger();
33
+ var systemLogTag = "__nfSystemLog";
34
+ var serializeError = (error) => {
35
+ const cause = error?.cause instanceof Error ? serializeError(error.cause) : error.cause;
36
+ return {
37
+ error: error.message,
38
+ error_cause: cause,
39
+ error_stack: error.stack
40
+ };
41
+ };
42
+ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
43
+ LogLevel2[LogLevel2["Debug"] = 1] = "Debug";
44
+ LogLevel2[LogLevel2["Log"] = 2] = "Log";
45
+ LogLevel2[LogLevel2["Error"] = 3] = "Error";
46
+ return LogLevel2;
47
+ })(LogLevel || {});
48
+ var SystemLogger = class _SystemLogger {
49
+ fields;
50
+ logLevel;
51
+ constructor(fields = {}, logLevel = 2) {
52
+ this.fields = fields;
53
+ this.logLevel = logLevel;
110
54
  }
111
- });
112
-
113
- // node_modules/@netlify/functions/dist/chunk-7ANA32NV.mjs
114
- var init_internal = __esm({
115
- "src/internal.ts"() {
116
- init_system_logger();
55
+ doLog(logger, message) {
56
+ if (import_process.env.NETLIFY_DEV && !import_process.env.NETLIFY_ENABLE_SYSTEM_LOGGING) {
57
+ return;
58
+ }
59
+ logger(systemLogTag, JSON.stringify({ msg: message, fields: this.fields }));
117
60
  }
118
- });
119
-
120
- // node_modules/@netlify/functions/dist/internal.mjs
121
- init_internal();
61
+ log(message) {
62
+ if (this.logLevel > 2) {
63
+ return;
64
+ }
65
+ this.doLog(console.log, message);
66
+ }
67
+ debug(message) {
68
+ if (this.logLevel > 1) {
69
+ return;
70
+ }
71
+ this.doLog(console.debug, message);
72
+ }
73
+ error(message) {
74
+ if (this.logLevel > 3) {
75
+ return;
76
+ }
77
+ this.doLog(console.error, message);
78
+ }
79
+ withLogLevel(level) {
80
+ return new _SystemLogger(this.fields, level);
81
+ }
82
+ withFields(fields) {
83
+ return new _SystemLogger(
84
+ {
85
+ ...this.fields,
86
+ ...fields
87
+ },
88
+ this.logLevel
89
+ );
90
+ }
91
+ withError(error) {
92
+ const fields = error instanceof Error ? serializeError(error) : { error };
93
+ return this.withFields(fields);
94
+ }
95
+ };
96
+ var systemLogger = new SystemLogger();
122
97
 
123
98
  // src/run/handlers/request-context.cts
124
99
  var REQUEST_CONTEXT_GLOBAL_KEY = Symbol.for("nf-request-context-async-local-storage");
@@ -7,7 +7,7 @@
7
7
  import {
8
8
  __commonJS,
9
9
  __toESM
10
- } from "../../esm-chunks/chunk-OEQOKJGE.js";
10
+ } from "../../esm-chunks/chunk-6BT4RYQJ.js";
11
11
 
12
12
  // node_modules/node-inspect-extracted/dist/inspect.js
13
13
  var require_inspect = __commonJS({
@@ -3091,6 +3091,7 @@ function toComputeResponse(res) {
3091
3091
  }
3092
3092
 
3093
3093
  // src/run/handlers/server.ts
3094
+ import { getRunConfig, setRunConfig } from "../config.js";
3094
3095
  import {
3095
3096
  adjustDateHeader,
3096
3097
  setCacheControlHeaders,
@@ -3102,12 +3103,17 @@ import { nextResponseProxy } from "../revalidate.js";
3102
3103
  import { setFetchBeforeNextPatchedIt } from "../storage/storage.cjs";
3103
3104
  import { getLogger } from "./request-context.cjs";
3104
3105
  import { getTracer, recordWarning } from "./tracer.cjs";
3106
+ import { configureUseCacheHandlers } from "./use-cache-handler.js";
3105
3107
  import { setupWaitUntil } from "./wait-until.cjs";
3106
3108
  setFetchBeforeNextPatchedIt(globalThis.fetch);
3107
- var nextImportPromise = import("../next.cjs");
3109
+ var { nextConfig, enableUseCacheHandler } = await getRunConfig();
3110
+ if (enableUseCacheHandler) {
3111
+ configureUseCacheHandlers();
3112
+ }
3113
+ setRunConfig(nextConfig);
3108
3114
  setupWaitUntil();
3115
+ var nextImportPromise = import("../next.cjs");
3109
3116
  var nextHandler;
3110
- var nextConfig;
3111
3117
  var disableFaultyTransferEncodingHandling = (res) => {
3112
3118
  const originalStoreHeader = res._storeHeader;
3113
3119
  res._storeHeader = function _storeHeader(firstLine, headers) {
@@ -3125,9 +3131,6 @@ var server_default = async (request, _context, topLevelSpan, requestContext) =>
3125
3131
  const tracer = getTracer();
3126
3132
  if (!nextHandler) {
3127
3133
  await tracer.withActiveSpan("initialize next server", async () => {
3128
- const { getRunConfig, setRunConfig } = await import("../config.js");
3129
- nextConfig = await getRunConfig();
3130
- setRunConfig(nextConfig);
3131
3134
  const { getMockedRequestHandler } = await nextImportPromise;
3132
3135
  const url = new URL(request.url);
3133
3136
  nextHandler = await getMockedRequestHandler({