@netlify/plugin-nextjs 5.14.1 → 5.14.3
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/dist/build/functions/edge.js +1 -1
- package/dist/build/templates/handler-monorepo.tmpl.js +4 -4
- package/dist/build/templates/handler.tmpl.js +4 -4
- package/dist/run/handlers/cache.cjs +13 -13
- package/dist/run/handlers/server.js +7 -7
- package/dist/run/handlers/tags-handler.cjs +1 -1
- package/dist/run/handlers/tracer.cjs +728 -641
- package/dist/run/handlers/use-cache-handler.js +23 -18
- package/dist/run/next.cjs +1 -2
- package/dist/run/storage/storage.cjs +5 -5
- package/package.json +1 -1
|
@@ -463,7 +463,7 @@ var writeHandlerFile = async (ctx, { matchers, name }) => {
|
|
|
463
463
|
basePath: nextConfig.basePath,
|
|
464
464
|
i18n: nextConfig.i18n,
|
|
465
465
|
trailingSlash: nextConfig.trailingSlash,
|
|
466
|
-
skipMiddlewareUrlNormalize: nextConfig.skipMiddlewareUrlNormalize
|
|
466
|
+
skipMiddlewareUrlNormalize: nextConfig.skipProxyUrlNormalize ?? nextConfig.skipMiddlewareUrlNormalize
|
|
467
467
|
};
|
|
468
468
|
await writeFile(
|
|
469
469
|
join(handlerRuntimeDirectory, "next.config.json"),
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
createRequestContext,
|
|
3
3
|
runWithRequestContext,
|
|
4
4
|
} from '{{cwd}}/.netlify/dist/run/handlers/request-context.cjs'
|
|
5
|
-
import { getTracer } from '{{cwd}}/.netlify/dist/run/handlers/tracer.cjs'
|
|
5
|
+
import { getTracer, withActiveSpan } from '{{cwd}}/.netlify/dist/run/handlers/tracer.cjs'
|
|
6
6
|
|
|
7
7
|
process.chdir('{{cwd}}')
|
|
8
8
|
|
|
@@ -15,8 +15,8 @@ export default async function (req, context) {
|
|
|
15
15
|
const tracer = getTracer()
|
|
16
16
|
|
|
17
17
|
const handlerResponse = await runWithRequestContext(requestContext, () => {
|
|
18
|
-
return
|
|
19
|
-
span
|
|
18
|
+
return withActiveSpan(tracer, 'Next.js Server Handler', async (span) => {
|
|
19
|
+
span?.setAttributes({
|
|
20
20
|
'account.id': context.account.id,
|
|
21
21
|
'deploy.id': context.deploy.id,
|
|
22
22
|
'request.id': context.requestId,
|
|
@@ -32,7 +32,7 @@ export default async function (req, context) {
|
|
|
32
32
|
cachedHandler = handler
|
|
33
33
|
}
|
|
34
34
|
const response = await cachedHandler(req, context, span, requestContext)
|
|
35
|
-
span
|
|
35
|
+
span?.setAttributes({
|
|
36
36
|
'http.status_code': response.status,
|
|
37
37
|
})
|
|
38
38
|
return response
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
runWithRequestContext,
|
|
4
4
|
} from './.netlify/dist/run/handlers/request-context.cjs'
|
|
5
5
|
import serverHandler from './.netlify/dist/run/handlers/server.js'
|
|
6
|
-
import { getTracer } from './.netlify/dist/run/handlers/tracer.cjs'
|
|
6
|
+
import { getTracer, withActiveSpan } from './.netlify/dist/run/handlers/tracer.cjs'
|
|
7
7
|
|
|
8
8
|
// Set feature flag for regional blobs
|
|
9
9
|
process.env.USE_REGIONAL_BLOBS = '{{useRegionalBlobs}}'
|
|
@@ -13,8 +13,8 @@ export default async function handler(req, context) {
|
|
|
13
13
|
const tracer = getTracer()
|
|
14
14
|
|
|
15
15
|
const handlerResponse = await runWithRequestContext(requestContext, () => {
|
|
16
|
-
return
|
|
17
|
-
span
|
|
16
|
+
return withActiveSpan(tracer, 'Next.js Server Handler', async (span) => {
|
|
17
|
+
span?.setAttributes({
|
|
18
18
|
'account.id': context.account.id,
|
|
19
19
|
'deploy.id': context.deploy.id,
|
|
20
20
|
'request.id': context.requestId,
|
|
@@ -26,7 +26,7 @@ export default async function handler(req, context) {
|
|
|
26
26
|
cwd: process.cwd(),
|
|
27
27
|
})
|
|
28
28
|
const response = await serverHandler(req, context, span, requestContext)
|
|
29
|
-
span
|
|
29
|
+
span?.setAttributes({
|
|
30
30
|
'http.status_code': response.status,
|
|
31
31
|
})
|
|
32
32
|
return response
|
|
@@ -181,18 +181,18 @@ var NetlifyCacheHandler = class {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
async get(...args) {
|
|
184
|
-
return this.tracer
|
|
184
|
+
return (0, import_tracer.withActiveSpan)(this.tracer, "get cache key", async (span) => {
|
|
185
185
|
const [key, context = {}] = args;
|
|
186
186
|
(0, import_request_context.getLogger)().debug(`[NetlifyCacheHandler.get]: ${key}`);
|
|
187
|
-
span
|
|
187
|
+
span?.setAttributes({ key });
|
|
188
188
|
const blob = await this.cacheStore.get(key, "blobStore.get");
|
|
189
189
|
if (!blob) {
|
|
190
|
-
span
|
|
190
|
+
span?.addEvent("Cache miss", { key });
|
|
191
191
|
return null;
|
|
192
192
|
}
|
|
193
193
|
const ttl = this.getTTL(blob);
|
|
194
194
|
if ((0, import_request_context.getRequestContext)()?.isBackgroundRevalidation && typeof ttl === "number" && ttl < 0) {
|
|
195
|
-
span
|
|
195
|
+
span?.addEvent("Discarding stale entry due to SWR background revalidation request", {
|
|
196
196
|
key,
|
|
197
197
|
ttl
|
|
198
198
|
});
|
|
@@ -210,12 +210,12 @@ var NetlifyCacheHandler = class {
|
|
|
210
210
|
context.softTags
|
|
211
211
|
);
|
|
212
212
|
if (expiredByTags) {
|
|
213
|
-
span
|
|
213
|
+
span?.addEvent("Expired", { expiredByTags, key, ttl });
|
|
214
214
|
return null;
|
|
215
215
|
}
|
|
216
216
|
this.captureResponseCacheLastModified(blob, key, span);
|
|
217
217
|
if (staleByTags) {
|
|
218
|
-
span
|
|
218
|
+
span?.addEvent("Stale", { staleByTags, key, ttl });
|
|
219
219
|
blob.lastModified = -1;
|
|
220
220
|
}
|
|
221
221
|
const isDataRequest = Boolean(context.fetchUrl);
|
|
@@ -224,7 +224,7 @@ var NetlifyCacheHandler = class {
|
|
|
224
224
|
}
|
|
225
225
|
switch (blob.value?.kind) {
|
|
226
226
|
case "FETCH":
|
|
227
|
-
span
|
|
227
|
+
span?.addEvent("FETCH", {
|
|
228
228
|
lastModified: blob.lastModified,
|
|
229
229
|
revalidate: context.revalidate,
|
|
230
230
|
ttl
|
|
@@ -235,7 +235,7 @@ var NetlifyCacheHandler = class {
|
|
|
235
235
|
};
|
|
236
236
|
case "ROUTE":
|
|
237
237
|
case "APP_ROUTE": {
|
|
238
|
-
span
|
|
238
|
+
span?.addEvent(blob.value?.kind, {
|
|
239
239
|
lastModified: blob.lastModified,
|
|
240
240
|
status: blob.value.status,
|
|
241
241
|
revalidate: blob.value.revalidate,
|
|
@@ -257,7 +257,7 @@ var NetlifyCacheHandler = class {
|
|
|
257
257
|
if (requestContext) {
|
|
258
258
|
requestContext.pageHandlerRevalidate = revalidate;
|
|
259
259
|
}
|
|
260
|
-
span
|
|
260
|
+
span?.addEvent(blob.value?.kind, { lastModified: blob.lastModified, revalidate, ttl });
|
|
261
261
|
await this.injectEntryToPrerenderManifest(key, blob.value);
|
|
262
262
|
return {
|
|
263
263
|
lastModified: blob.lastModified,
|
|
@@ -270,7 +270,7 @@ var NetlifyCacheHandler = class {
|
|
|
270
270
|
requestContext.isCacheableAppPage = true;
|
|
271
271
|
}
|
|
272
272
|
const { revalidate, rscData, segmentData, ...restOfPageValue } = blob.value;
|
|
273
|
-
span
|
|
273
|
+
span?.addEvent(blob.value?.kind, { lastModified: blob.lastModified, revalidate, ttl });
|
|
274
274
|
await this.injectEntryToPrerenderManifest(key, blob.value);
|
|
275
275
|
return {
|
|
276
276
|
lastModified: blob.lastModified,
|
|
@@ -287,7 +287,7 @@ var NetlifyCacheHandler = class {
|
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
289
|
default:
|
|
290
|
-
span
|
|
290
|
+
span?.recordException(new Error(`Unknown cache entry kind: ${blob.value?.kind}`));
|
|
291
291
|
}
|
|
292
292
|
return null;
|
|
293
293
|
});
|
|
@@ -328,10 +328,10 @@ var NetlifyCacheHandler = class {
|
|
|
328
328
|
return data;
|
|
329
329
|
}
|
|
330
330
|
async set(...args) {
|
|
331
|
-
return this.tracer
|
|
331
|
+
return (0, import_tracer.withActiveSpan)(this.tracer, "set cache key", async (span) => {
|
|
332
332
|
const [key, data, context] = args;
|
|
333
333
|
const lastModified = Date.now();
|
|
334
|
-
span
|
|
334
|
+
span?.setAttributes({ key, lastModified });
|
|
335
335
|
(0, import_request_context.getLogger)().debug(`[NetlifyCacheHandler.set]: ${key}`);
|
|
336
336
|
const value = this.transformToStorableObject(data, context);
|
|
337
337
|
const isDataReq = Boolean(context.fetchUrl);
|
|
@@ -3102,7 +3102,7 @@ import {
|
|
|
3102
3102
|
import { nextResponseProxy } from "../revalidate.js";
|
|
3103
3103
|
import { setFetchBeforeNextPatchedIt } from "../storage/storage.cjs";
|
|
3104
3104
|
import { getLogger } from "./request-context.cjs";
|
|
3105
|
-
import { getTracer, recordWarning } from "./tracer.cjs";
|
|
3105
|
+
import { getTracer, recordWarning, withActiveSpan } from "./tracer.cjs";
|
|
3106
3106
|
import { configureUseCacheHandlers } from "./use-cache-handler.js";
|
|
3107
3107
|
import { setupWaitUntil } from "./wait-until.cjs";
|
|
3108
3108
|
setFetchBeforeNextPatchedIt(globalThis.fetch);
|
|
@@ -3130,7 +3130,7 @@ var disableFaultyTransferEncodingHandling = (res) => {
|
|
|
3130
3130
|
var server_default = async (request, _context, topLevelSpan, requestContext) => {
|
|
3131
3131
|
const tracer = getTracer();
|
|
3132
3132
|
if (!nextHandler) {
|
|
3133
|
-
await
|
|
3133
|
+
await withActiveSpan(tracer, "initialize next server", async () => {
|
|
3134
3134
|
const { getMockedRequestHandler } = await nextImportPromise;
|
|
3135
3135
|
const url = new URL(request.url);
|
|
3136
3136
|
nextHandler = await getMockedRequestHandler(nextConfig, {
|
|
@@ -3141,7 +3141,7 @@ var server_default = async (request, _context, topLevelSpan, requestContext) =>
|
|
|
3141
3141
|
});
|
|
3142
3142
|
});
|
|
3143
3143
|
}
|
|
3144
|
-
return await
|
|
3144
|
+
return await withActiveSpan(tracer, "generate response", async (span) => {
|
|
3145
3145
|
const { req, res } = toReqRes(request);
|
|
3146
3146
|
Object.defineProperty(req, "connection", {
|
|
3147
3147
|
get() {
|
|
@@ -3159,12 +3159,12 @@ var server_default = async (request, _context, topLevelSpan, requestContext) =>
|
|
|
3159
3159
|
getLogger().withError(error).error("next handler error");
|
|
3160
3160
|
console.error(error);
|
|
3161
3161
|
resProxy.statusCode = 500;
|
|
3162
|
-
span
|
|
3162
|
+
span?.setAttribute("http.status_code", 500);
|
|
3163
3163
|
resProxy.end("Internal Server Error");
|
|
3164
3164
|
});
|
|
3165
3165
|
const response = await toComputeResponse(resProxy);
|
|
3166
3166
|
if (requestContext.responseCacheKey) {
|
|
3167
|
-
topLevelSpan
|
|
3167
|
+
topLevelSpan?.setAttribute("responseCacheKey", requestContext.responseCacheKey);
|
|
3168
3168
|
}
|
|
3169
3169
|
const nextCache = response.headers.get("x-nextjs-cache");
|
|
3170
3170
|
const isServedFromNextCache = nextCache === "HIT" || nextCache === "STALE";
|
|
@@ -3182,7 +3182,7 @@ var server_default = async (request, _context, topLevelSpan, requestContext) =>
|
|
|
3182
3182
|
setCacheStatusHeader(response.headers, nextCache);
|
|
3183
3183
|
const netlifyVary = response.headers.get("netlify-vary") ?? void 0;
|
|
3184
3184
|
const netlifyCdnCacheControl = response.headers.get("netlify-cdn-cache-control") ?? void 0;
|
|
3185
|
-
topLevelSpan
|
|
3185
|
+
topLevelSpan?.setAttributes({
|
|
3186
3186
|
"x-nextjs-cache": nextCache ?? void 0,
|
|
3187
3187
|
isServedFromNextCache,
|
|
3188
3188
|
netlifyVary,
|
|
@@ -3192,7 +3192,7 @@ var server_default = async (request, _context, topLevelSpan, requestContext) =>
|
|
|
3192
3192
|
const isRSCRequest = request.headers.get("rsc") === "1";
|
|
3193
3193
|
const contentType = response.headers.get("content-type") ?? void 0;
|
|
3194
3194
|
const isExpectedContentType = (isRSCRequest && contentType?.includes("text/x-component") || !isRSCRequest && contentType?.includes("text/html")) ?? false;
|
|
3195
|
-
topLevelSpan
|
|
3195
|
+
topLevelSpan?.setAttributes({
|
|
3196
3196
|
isRSCRequest,
|
|
3197
3197
|
isCacheableAppPage: true,
|
|
3198
3198
|
contentType,
|
|
@@ -86,7 +86,7 @@ var pipeline = (0, import_util.promisify)(import_stream.pipeline);
|
|
|
86
86
|
|
|
87
87
|
// package.json
|
|
88
88
|
var name = "@netlify/plugin-nextjs";
|
|
89
|
-
var version = "5.14.
|
|
89
|
+
var version = "5.14.3";
|
|
90
90
|
|
|
91
91
|
// src/run/handlers/tags-handler.cts
|
|
92
92
|
var import_storage = require("../storage/storage.cjs");
|