@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
|
@@ -1385,7 +1385,7 @@ import {
|
|
|
1385
1385
|
isAnyTagStaleOrExpired,
|
|
1386
1386
|
markTagsAsStaleAndPurgeEdgeCache
|
|
1387
1387
|
} from "./tags-handler.cjs";
|
|
1388
|
-
import { getTracer } from "./tracer.cjs";
|
|
1388
|
+
import { getTracer, withActiveSpan } from "./tracer.cjs";
|
|
1389
1389
|
var LRU_CACHE_GLOBAL_KEY = Symbol.for("nf-use-cache-handler-lru-cache");
|
|
1390
1390
|
var PENDING_SETS_GLOBAL_KEY = Symbol.for("nf-use-cache-handler-pending-sets");
|
|
1391
1391
|
var cacheHandlersSymbol = Symbol.for("@next/cache-handlers");
|
|
@@ -1415,11 +1415,12 @@ var tmpResolvePendingBeforeCreatingAPromise = () => {
|
|
|
1415
1415
|
};
|
|
1416
1416
|
var NetlifyDefaultUseCacheHandler = {
|
|
1417
1417
|
get(cacheKey) {
|
|
1418
|
-
return
|
|
1418
|
+
return withActiveSpan(
|
|
1419
|
+
getTracer(),
|
|
1419
1420
|
"DefaultUseCacheHandler.get",
|
|
1420
1421
|
async (span) => {
|
|
1421
1422
|
getLogger().withFields({ cacheKey }).debug(`[NetlifyDefaultUseCacheHandler] get`);
|
|
1422
|
-
span
|
|
1423
|
+
span?.setAttributes({
|
|
1423
1424
|
cacheKey
|
|
1424
1425
|
});
|
|
1425
1426
|
const pendingPromise = getPendingSets().get(cacheKey);
|
|
@@ -1429,7 +1430,7 @@ var NetlifyDefaultUseCacheHandler = {
|
|
|
1429
1430
|
const privateEntry = getLRUCache().get(cacheKey);
|
|
1430
1431
|
if (!privateEntry) {
|
|
1431
1432
|
getLogger().withFields({ cacheKey, status: "MISS" }).debug(`[NetlifyDefaultUseCacheHandler] get result`);
|
|
1432
|
-
span
|
|
1433
|
+
span?.setAttributes({
|
|
1433
1434
|
cacheStatus: "miss"
|
|
1434
1435
|
});
|
|
1435
1436
|
return void 0;
|
|
@@ -1438,7 +1439,7 @@ var NetlifyDefaultUseCacheHandler = {
|
|
|
1438
1439
|
const ttl = (entry.timestamp + entry.revalidate * 1e3 - Date.now()) / 1e3;
|
|
1439
1440
|
if (ttl < 0) {
|
|
1440
1441
|
getLogger().withFields({ cacheKey, ttl, status: "STALE" }).debug(`[NetlifyDefaultUseCacheHandler] get result`);
|
|
1441
|
-
span
|
|
1442
|
+
span?.setAttributes({
|
|
1442
1443
|
cacheStatus: "expired, discarded",
|
|
1443
1444
|
ttl
|
|
1444
1445
|
});
|
|
@@ -1447,7 +1448,7 @@ var NetlifyDefaultUseCacheHandler = {
|
|
|
1447
1448
|
const { stale, expired } = await isAnyTagStaleOrExpired(entry.tags, entry.timestamp);
|
|
1448
1449
|
if (expired) {
|
|
1449
1450
|
getLogger().withFields({ cacheKey, ttl, status: "EXPIRED BY TAG" }).debug(`[NetlifyDefaultUseCacheHandler] get result`);
|
|
1450
|
-
span
|
|
1451
|
+
span?.setAttributes({
|
|
1451
1452
|
cacheStatus: "expired tag, discarded",
|
|
1452
1453
|
ttl
|
|
1453
1454
|
});
|
|
@@ -1460,7 +1461,7 @@ var NetlifyDefaultUseCacheHandler = {
|
|
|
1460
1461
|
const [returnStream, newSaved] = value.tee();
|
|
1461
1462
|
entry.value = newSaved;
|
|
1462
1463
|
getLogger().withFields({ cacheKey, ttl, status: stale ? "STALE" : "HIT" }).debug(`[NetlifyDefaultUseCacheHandler] get result`);
|
|
1463
|
-
span
|
|
1464
|
+
span?.setAttributes({
|
|
1464
1465
|
cacheStatus: stale ? "stale" : "hit",
|
|
1465
1466
|
ttl
|
|
1466
1467
|
});
|
|
@@ -1473,11 +1474,12 @@ var NetlifyDefaultUseCacheHandler = {
|
|
|
1473
1474
|
);
|
|
1474
1475
|
},
|
|
1475
1476
|
set(cacheKey, pendingEntry) {
|
|
1476
|
-
return
|
|
1477
|
+
return withActiveSpan(
|
|
1478
|
+
getTracer(),
|
|
1477
1479
|
"DefaultUseCacheHandler.set",
|
|
1478
1480
|
async (span) => {
|
|
1479
1481
|
getLogger().withFields({ cacheKey }).debug(`[NetlifyDefaultUseCacheHandler]: set`);
|
|
1480
|
-
span
|
|
1482
|
+
span?.setAttributes({
|
|
1481
1483
|
cacheKey
|
|
1482
1484
|
});
|
|
1483
1485
|
let resolvePending = tmpResolvePendingBeforeCreatingAPromise;
|
|
@@ -1487,7 +1489,7 @@ var NetlifyDefaultUseCacheHandler = {
|
|
|
1487
1489
|
const pendingSets = getPendingSets();
|
|
1488
1490
|
pendingSets.set(cacheKey, pendingPromise);
|
|
1489
1491
|
const entry = await pendingEntry;
|
|
1490
|
-
span
|
|
1492
|
+
span?.setAttributes({
|
|
1491
1493
|
cacheKey
|
|
1492
1494
|
});
|
|
1493
1495
|
let size = 0;
|
|
@@ -1498,7 +1500,7 @@ var NetlifyDefaultUseCacheHandler = {
|
|
|
1498
1500
|
for (let chunk; !(chunk = await reader.read()).done; ) {
|
|
1499
1501
|
size += Buffer.from(chunk.value).byteLength;
|
|
1500
1502
|
}
|
|
1501
|
-
span
|
|
1503
|
+
span?.setAttributes({
|
|
1502
1504
|
tags: entry.tags,
|
|
1503
1505
|
timestamp: entry.timestamp,
|
|
1504
1506
|
revalidate: entry.revalidate,
|
|
@@ -1520,16 +1522,17 @@ var NetlifyDefaultUseCacheHandler = {
|
|
|
1520
1522
|
async refreshTags() {
|
|
1521
1523
|
},
|
|
1522
1524
|
getExpiration: function(...notNormalizedTags) {
|
|
1523
|
-
return
|
|
1525
|
+
return withActiveSpan(
|
|
1526
|
+
getTracer(),
|
|
1524
1527
|
"DefaultUseCacheHandler.getExpiration",
|
|
1525
1528
|
async (span) => {
|
|
1526
1529
|
const tags = notNormalizedTags.flat();
|
|
1527
|
-
span
|
|
1530
|
+
span?.setAttributes({
|
|
1528
1531
|
tags
|
|
1529
1532
|
});
|
|
1530
1533
|
const expiration = await getMostRecentTagExpirationTimestamp(tags);
|
|
1531
1534
|
getLogger().withFields({ tags, expiration }).debug(`[NetlifyDefaultUseCacheHandler] getExpiration`);
|
|
1532
|
-
span
|
|
1535
|
+
span?.setAttributes({
|
|
1533
1536
|
expiration
|
|
1534
1537
|
});
|
|
1535
1538
|
return expiration;
|
|
@@ -1538,11 +1541,12 @@ var NetlifyDefaultUseCacheHandler = {
|
|
|
1538
1541
|
},
|
|
1539
1542
|
// this is for CacheHandlerV2
|
|
1540
1543
|
expireTags(...tags) {
|
|
1541
|
-
return
|
|
1544
|
+
return withActiveSpan(
|
|
1545
|
+
getTracer(),
|
|
1542
1546
|
"DefaultUseCacheHandler.expireTags",
|
|
1543
1547
|
async (span) => {
|
|
1544
1548
|
getLogger().withFields({ tags }).debug(`[NetlifyDefaultUseCacheHandler] expireTags`);
|
|
1545
|
-
span
|
|
1549
|
+
span?.setAttributes({
|
|
1546
1550
|
tags
|
|
1547
1551
|
});
|
|
1548
1552
|
await markTagsAsStaleAndPurgeEdgeCache(tags);
|
|
@@ -1551,11 +1555,12 @@ var NetlifyDefaultUseCacheHandler = {
|
|
|
1551
1555
|
},
|
|
1552
1556
|
// this is for CacheHandlerV3 / Next 16
|
|
1553
1557
|
updateTags(tags, durations) {
|
|
1554
|
-
return
|
|
1558
|
+
return withActiveSpan(
|
|
1559
|
+
getTracer(),
|
|
1555
1560
|
"DefaultUseCacheHandler.updateTags",
|
|
1556
1561
|
async (span) => {
|
|
1557
1562
|
getLogger().withFields({ tags, durations }).debug(`[NetlifyDefaultUseCacheHandler] updateTags`);
|
|
1558
|
-
span
|
|
1563
|
+
span?.setAttributes({
|
|
1559
1564
|
tags,
|
|
1560
1565
|
durations: JSON.stringify(durations)
|
|
1561
1566
|
});
|
package/dist/run/next.cjs
CHANGED
|
@@ -545,8 +545,7 @@ ResponseCache.prototype.get = function get(...getArgs) {
|
|
|
545
545
|
async function getMockedRequestHandler(nextConfig, ...args) {
|
|
546
546
|
const initContext = { initializingServer: true };
|
|
547
547
|
const initAsyncLocalStorage = new import_node_async_hooks.AsyncLocalStorage();
|
|
548
|
-
|
|
549
|
-
return tracer.withActiveSpan("mocked request handler", async () => {
|
|
548
|
+
return (0, import_tracer.withActiveSpan)((0, import_tracer.getTracer)(), "mocked request handler", async () => {
|
|
550
549
|
const ofs = { ...import_promises.default };
|
|
551
550
|
async function readFileFallbackBlobStore(...fsargs) {
|
|
552
551
|
const [path, options] = fsargs;
|
|
@@ -55,11 +55,11 @@ var getMemoizedKeyValueStoreBackedByRegionalBlobStore = (...args) => {
|
|
|
55
55
|
return memoizedValue;
|
|
56
56
|
}
|
|
57
57
|
const blobKey = await encodeBlobKey(key);
|
|
58
|
-
const getPromise =
|
|
59
|
-
span
|
|
58
|
+
const getPromise = (0, import_tracer.withActiveSpan)(tracer, otelSpanTitle, async (span) => {
|
|
59
|
+
span?.setAttributes({ key, blobKey });
|
|
60
60
|
const blob = await store.get(blobKey, { type: "json" });
|
|
61
61
|
inMemoryCache.set(key, blob);
|
|
62
|
-
span
|
|
62
|
+
span?.addEvent(blob ? "Hit" : "Miss");
|
|
63
63
|
return blob;
|
|
64
64
|
});
|
|
65
65
|
inMemoryCache.set(key, getPromise);
|
|
@@ -69,8 +69,8 @@ var getMemoizedKeyValueStoreBackedByRegionalBlobStore = (...args) => {
|
|
|
69
69
|
const inMemoryCache = (0, import_request_scoped_in_memory_cache.getRequestScopedInMemoryCache)();
|
|
70
70
|
inMemoryCache.set(key, value);
|
|
71
71
|
const blobKey = await encodeBlobKey(key);
|
|
72
|
-
return
|
|
73
|
-
span
|
|
72
|
+
return (0, import_tracer.withActiveSpan)(tracer, otelSpanTitle, async (span) => {
|
|
73
|
+
span?.setAttributes({ key, blobKey });
|
|
74
74
|
return await store.setJSON(blobKey, value);
|
|
75
75
|
});
|
|
76
76
|
}
|