next 15.6.0-canary.7 → 15.6.0-canary.8
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/bin/next +1 -1
- package/dist/build/index.js +3 -3
- package/dist/build/swc/index.js +1 -1
- package/dist/build/webpack-config.js +4 -4
- package/dist/build/webpack-config.js.map +1 -1
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/compiled/babel-packages/packages-bundle.js +7 -7
- package/dist/compiled/next-server/server.runtime.prod.js +1 -1
- package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
- package/dist/esm/build/index.js +3 -3
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/webpack-config.js +4 -4
- package/dist/esm/build/webpack-config.js.map +1 -1
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/server/base-server.js +0 -3
- package/dist/esm/server/base-server.js.map +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/server/route-matcher-managers/dev-route-matcher-manager.js +3 -0
- package/dist/esm/server/route-matcher-managers/dev-route-matcher-manager.js.map +1 -1
- package/dist/esm/server/web/spec-extension/unstable-cache.js +26 -6
- package/dist/esm/server/web/spec-extension/unstable-cache.js.map +1 -1
- package/dist/esm/shared/lib/canary-only.js +1 -1
- package/dist/server/base-server.d.ts +0 -1
- package/dist/server/base-server.js +0 -3
- package/dist/server/base-server.js.map +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/server/route-matcher-managers/dev-route-matcher-manager.js +3 -0
- package/dist/server/route-matcher-managers/dev-route-matcher-manager.js.map +1 -1
- package/dist/server/web/spec-extension/unstable-cache.js +26 -6
- package/dist/server/web/spec-extension/unstable-cache.js.map +1 -1
- package/dist/shared/lib/canary-only.js +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +15 -15
@@ -90,7 +90,7 @@ export async function createHotReloaderTurbopack(opts, serverFields, distDir, re
|
|
90
90
|
}
|
91
91
|
const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
|
92
92
|
const hotReloaderSpan = trace('hot-reloader', undefined, {
|
93
|
-
version: "15.6.0-canary.
|
93
|
+
version: "15.6.0-canary.8"
|
94
94
|
});
|
95
95
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
96
96
|
// of the current `next dev` invocation.
|
@@ -158,7 +158,7 @@ export default class HotReloaderWebpack {
|
|
158
158
|
this.previewProps = previewProps;
|
159
159
|
this.rewrites = rewrites;
|
160
160
|
this.hotReloaderSpan = trace('hot-reloader', undefined, {
|
161
|
-
version: "15.6.0-canary.
|
161
|
+
version: "15.6.0-canary.8"
|
162
162
|
});
|
163
163
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
164
164
|
// of the current `next dev` invocation.
|
@@ -14,7 +14,7 @@ export function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures
|
|
14
14
|
bundlerSuffix = ' (webpack)';
|
15
15
|
}
|
16
16
|
}
|
17
|
-
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.6.0-canary.
|
17
|
+
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.6.0-canary.8"}`))}${bundlerSuffix}`);
|
18
18
|
if (appUrl) {
|
19
19
|
Log.bootstrap(`- Local: ${appUrl}`);
|
20
20
|
}
|
@@ -111,7 +111,7 @@ export async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup,
|
|
111
111
|
export async function startServer(serverOptions) {
|
112
112
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
113
113
|
let { port } = serverOptions;
|
114
|
-
process.title = `next-server (v${"15.6.0-canary.
|
114
|
+
process.title = `next-server (v${"15.6.0-canary.8"})`;
|
115
115
|
let handlersReady = ()=>{};
|
116
116
|
let handlersError = ()=>{};
|
117
117
|
let handlersPromise = new Promise((resolve, reject)=>{
|
@@ -26,6 +26,9 @@ export class DevRouteMatcherManager extends DefaultRouteMatcherManager {
|
|
26
26
|
return match;
|
27
27
|
}
|
28
28
|
async *matchAll(pathname, options) {
|
29
|
+
// Compile the development routes.
|
30
|
+
// TODO: we may want to only run this during testing, users won't be fast enough to require this many dir scans
|
31
|
+
await super.reload();
|
29
32
|
// Iterate over the development matches to see if one of them match the
|
30
33
|
// request path.
|
31
34
|
for await (const developmentMatch of super.matchAll(pathname, options)){
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/server/route-matcher-managers/dev-route-matcher-manager.ts"],"sourcesContent":["import { RouteKind } from '../route-kind'\nimport type { RouteMatch } from '../route-matches/route-match'\nimport type { RouteDefinition } from '../route-definitions/route-definition'\nimport { DefaultRouteMatcherManager } from './default-route-matcher-manager'\nimport type { MatchOptions, RouteMatcherManager } from './route-matcher-manager'\nimport path from '../../shared/lib/isomorphic/path'\nimport * as Log from '../../build/output/log'\nimport { cyan } from '../../lib/picocolors'\nimport type { RouteMatcher } from '../route-matchers/route-matcher'\n\nexport interface RouteEnsurer {\n ensure(match: RouteMatch, pathname: string): Promise<void>\n}\n\nexport class DevRouteMatcherManager extends DefaultRouteMatcherManager {\n constructor(\n private readonly production: RouteMatcherManager,\n private readonly ensurer: RouteEnsurer,\n private readonly dir: string\n ) {\n super()\n }\n\n public async test(pathname: string, options: MatchOptions): Promise<boolean> {\n // Try to find a match within the developer routes.\n const match = await super.match(pathname, options)\n\n // Return if the match wasn't null. Unlike the implementation of `match`\n // which uses `matchAll` here, this does not call `ensure` on the match\n // found via the development matches.\n return match !== null\n }\n\n protected validate(\n pathname: string,\n matcher: RouteMatcher,\n options: MatchOptions\n ): RouteMatch | null {\n const match = super.validate(pathname, matcher, options)\n\n // If a match was found, check to see if there were any conflicting app or\n // pages files.\n // TODO: maybe expand this to _any_ duplicated routes instead?\n if (\n match &&\n matcher.duplicated &&\n matcher.duplicated.some(\n (duplicate) =>\n duplicate.definition.kind === RouteKind.APP_PAGE ||\n duplicate.definition.kind === RouteKind.APP_ROUTE\n ) &&\n matcher.duplicated.some(\n (duplicate) =>\n duplicate.definition.kind === RouteKind.PAGES ||\n duplicate.definition.kind === RouteKind.PAGES_API\n )\n ) {\n return null\n }\n\n return match\n }\n\n public async *matchAll(\n pathname: string,\n options: MatchOptions\n ): AsyncGenerator<RouteMatch<RouteDefinition<RouteKind>>, null, undefined> {\n // Iterate over the development matches to see if one of them match the\n // request path.\n for await (const developmentMatch of super.matchAll(pathname, options)) {\n // We're here, which means that we haven't seen this match yet, so we\n // should try to ensure it and recompile the production matcher.\n await this.ensurer.ensure(developmentMatch, pathname)\n await this.production.reload()\n\n // Iterate over the production matches again, this time we should be able\n // to match it against the production matcher unless there's an error.\n for await (const productionMatch of this.production.matchAll(\n pathname,\n options\n )) {\n yield productionMatch\n }\n }\n\n // We tried direct matching against the pathname and against all the dynamic\n // paths, so there was no match.\n return null\n }\n\n public async reload(): Promise<void> {\n // Compile the production routes again.\n await this.production.reload()\n\n // Compile the development routes.\n await super.reload()\n\n // Check for and warn of any duplicates.\n for (const [pathname, matchers] of Object.entries(\n this.matchers.duplicates\n )) {\n // We only want to warn about matchers resolving to the same path if their\n // identities are different.\n const identity = matchers[0].identity\n if (matchers.slice(1).some((matcher) => matcher.identity !== identity)) {\n continue\n }\n\n Log.warn(\n `Duplicate page detected. ${matchers\n .map((matcher) =>\n cyan(path.relative(this.dir, matcher.definition.filename))\n )\n .join(' and ')} resolve to ${cyan(pathname)}`\n )\n }\n }\n}\n"],"names":["RouteKind","DefaultRouteMatcherManager","path","Log","cyan","DevRouteMatcherManager","constructor","production","ensurer","dir","test","pathname","options","match","validate","matcher","duplicated","some","duplicate","definition","kind","APP_PAGE","APP_ROUTE","PAGES","PAGES_API","matchAll","
|
1
|
+
{"version":3,"sources":["../../../src/server/route-matcher-managers/dev-route-matcher-manager.ts"],"sourcesContent":["import { RouteKind } from '../route-kind'\nimport type { RouteMatch } from '../route-matches/route-match'\nimport type { RouteDefinition } from '../route-definitions/route-definition'\nimport { DefaultRouteMatcherManager } from './default-route-matcher-manager'\nimport type { MatchOptions, RouteMatcherManager } from './route-matcher-manager'\nimport path from '../../shared/lib/isomorphic/path'\nimport * as Log from '../../build/output/log'\nimport { cyan } from '../../lib/picocolors'\nimport type { RouteMatcher } from '../route-matchers/route-matcher'\n\nexport interface RouteEnsurer {\n ensure(match: RouteMatch, pathname: string): Promise<void>\n}\n\nexport class DevRouteMatcherManager extends DefaultRouteMatcherManager {\n constructor(\n private readonly production: RouteMatcherManager,\n private readonly ensurer: RouteEnsurer,\n private readonly dir: string\n ) {\n super()\n }\n\n public async test(pathname: string, options: MatchOptions): Promise<boolean> {\n // Try to find a match within the developer routes.\n const match = await super.match(pathname, options)\n\n // Return if the match wasn't null. Unlike the implementation of `match`\n // which uses `matchAll` here, this does not call `ensure` on the match\n // found via the development matches.\n return match !== null\n }\n\n protected validate(\n pathname: string,\n matcher: RouteMatcher,\n options: MatchOptions\n ): RouteMatch | null {\n const match = super.validate(pathname, matcher, options)\n\n // If a match was found, check to see if there were any conflicting app or\n // pages files.\n // TODO: maybe expand this to _any_ duplicated routes instead?\n if (\n match &&\n matcher.duplicated &&\n matcher.duplicated.some(\n (duplicate) =>\n duplicate.definition.kind === RouteKind.APP_PAGE ||\n duplicate.definition.kind === RouteKind.APP_ROUTE\n ) &&\n matcher.duplicated.some(\n (duplicate) =>\n duplicate.definition.kind === RouteKind.PAGES ||\n duplicate.definition.kind === RouteKind.PAGES_API\n )\n ) {\n return null\n }\n\n return match\n }\n\n public async *matchAll(\n pathname: string,\n options: MatchOptions\n ): AsyncGenerator<RouteMatch<RouteDefinition<RouteKind>>, null, undefined> {\n // Compile the development routes.\n // TODO: we may want to only run this during testing, users won't be fast enough to require this many dir scans\n await super.reload()\n\n // Iterate over the development matches to see if one of them match the\n // request path.\n for await (const developmentMatch of super.matchAll(pathname, options)) {\n // We're here, which means that we haven't seen this match yet, so we\n // should try to ensure it and recompile the production matcher.\n await this.ensurer.ensure(developmentMatch, pathname)\n await this.production.reload()\n\n // Iterate over the production matches again, this time we should be able\n // to match it against the production matcher unless there's an error.\n for await (const productionMatch of this.production.matchAll(\n pathname,\n options\n )) {\n yield productionMatch\n }\n }\n\n // We tried direct matching against the pathname and against all the dynamic\n // paths, so there was no match.\n return null\n }\n\n public async reload(): Promise<void> {\n // Compile the production routes again.\n await this.production.reload()\n\n // Compile the development routes.\n await super.reload()\n\n // Check for and warn of any duplicates.\n for (const [pathname, matchers] of Object.entries(\n this.matchers.duplicates\n )) {\n // We only want to warn about matchers resolving to the same path if their\n // identities are different.\n const identity = matchers[0].identity\n if (matchers.slice(1).some((matcher) => matcher.identity !== identity)) {\n continue\n }\n\n Log.warn(\n `Duplicate page detected. ${matchers\n .map((matcher) =>\n cyan(path.relative(this.dir, matcher.definition.filename))\n )\n .join(' and ')} resolve to ${cyan(pathname)}`\n )\n }\n }\n}\n"],"names":["RouteKind","DefaultRouteMatcherManager","path","Log","cyan","DevRouteMatcherManager","constructor","production","ensurer","dir","test","pathname","options","match","validate","matcher","duplicated","some","duplicate","definition","kind","APP_PAGE","APP_ROUTE","PAGES","PAGES_API","matchAll","reload","developmentMatch","ensure","productionMatch","matchers","Object","entries","duplicates","identity","slice","warn","map","relative","filename","join"],"mappings":"AAAA,SAASA,SAAS,QAAQ,gBAAe;AAGzC,SAASC,0BAA0B,QAAQ,kCAAiC;AAE5E,OA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,CAACD,kBAAkBhB;YAC5C,MAAM,IAAI,CAACJ,UAAU,CAACmB,MAAM;YAE5B,yEAAyE;YACzE,sEAAsE;YACtE,WAAW,MAAMG,mBAAmB,IAAI,CAACtB,UAAU,CAACkB,QAAQ,CAC1Dd,UACAC,SACC;gBACD,MAAMiB;YACR;QACF;QAEA,4EAA4E;QAC5E,gCAAgC;QAChC,OAAO;IACT;IAEA,MAAaH,SAAwB;QACnC,uCAAuC;QACvC,MAAM,IAAI,CAACnB,UAAU,CAACmB,MAAM;QAE5B,kCAAkC;QAClC,MAAM,KAAK,CAACA;QAEZ,wCAAwC;QACxC,KAAK,MAAM,CAACf,UAAUmB,SAAS,IAAIC,OAAOC,OAAO,CAC/C,IAAI,CAACF,QAAQ,CAACG,UAAU,EACvB;YACD,0EAA0E;YAC1E,4BAA4B;YAC5B,MAAMC,WAAWJ,QAAQ,CAAC,EAAE,CAACI,QAAQ;YACrC,IAAIJ,SAASK,KAAK,CAAC,GAAGlB,IAAI,CAAC,CAACF,UAAYA,QAAQmB,QAAQ,KAAKA,WAAW;gBACtE;YACF;YAEA/B,IAAIiC,IAAI,CACN,CAAC,yBAAyB,EAAEN,SACzBO,GAAG,CAAC,CAACtB,UACJX,KAAKF,KAAKoC,QAAQ,CAAC,IAAI,CAAC7B,GAAG,EAAEM,QAAQI,UAAU,CAACoB,QAAQ,IAEzDC,IAAI,CAAC,SAAS,YAAY,EAAEpC,KAAKO,WAAW;QAEnD;IACF;AACF","ignoreList":[0]}
|
@@ -158,15 +158,35 @@ async function cacheNewResult(result, incrementalCache, cacheKey, tags, revalida
|
|
158
158
|
// to background revalidate it by checking if it is stale.
|
159
159
|
const cachedResponse = cacheEntry.value.data.body !== undefined ? JSON.parse(cacheEntry.value.data.body) : undefined;
|
160
160
|
if (cacheEntry.isStale) {
|
161
|
-
// In App Router we return the stale result and revalidate in the background
|
162
161
|
if (!workStore.pendingRevalidates) {
|
163
162
|
workStore.pendingRevalidates = {};
|
164
163
|
}
|
165
|
-
//
|
166
|
-
workStore.pendingRevalidates[invocationKey]
|
167
|
-
|
168
|
-
|
169
|
-
|
164
|
+
// Check if there's already a pending revalidation to avoid duplicate work
|
165
|
+
if (!workStore.pendingRevalidates[invocationKey]) {
|
166
|
+
// Create the revalidation promise
|
167
|
+
const revalidationPromise = workUnitAsyncStorage.run(innerCacheStore, cb, ...args).then(async (result)=>{
|
168
|
+
await cacheNewResult(result, incrementalCache, cacheKey, tags, options.revalidate, fetchIdx, fetchUrl);
|
169
|
+
return result;
|
170
|
+
}).catch((err)=>{
|
171
|
+
// @TODO This error handling seems wrong. We swallow the error?
|
172
|
+
console.error(`revalidating cache with key: ${invocationKey}`, err);
|
173
|
+
// Return the stale value on error for foreground revalidation
|
174
|
+
return cachedResponse;
|
175
|
+
});
|
176
|
+
// Attach the empty catch here so we don't get a "unhandled promise
|
177
|
+
// rejection" warning. (Behavior is matched with patch-fetch)
|
178
|
+
if (workStore.isRevalidate) {
|
179
|
+
revalidationPromise.catch(()=>{});
|
180
|
+
}
|
181
|
+
workStore.pendingRevalidates[invocationKey] = revalidationPromise;
|
182
|
+
}
|
183
|
+
// Check if we need to do foreground revalidation
|
184
|
+
if (workStore.isRevalidate) {
|
185
|
+
// When the page is revalidating and the cache entry is stale,
|
186
|
+
// we need to wait for fresh data (blocking revalidate)
|
187
|
+
return workStore.pendingRevalidates[invocationKey];
|
188
|
+
}
|
189
|
+
// Otherwise, we're doing background revalidation - return stale immediately
|
170
190
|
}
|
171
191
|
// We had a valid cache entry so we return it here
|
172
192
|
return cachedResponse;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/server/web/spec-extension/unstable-cache.ts"],"sourcesContent":["import type { IncrementalCache } from '../../lib/incremental-cache'\n\nimport { CACHE_ONE_YEAR } from '../../../lib/constants'\nimport { validateRevalidate, validateTags } from '../../lib/patch-fetch'\nimport {\n workAsyncStorage,\n type WorkStore,\n} from '../../app-render/work-async-storage.external'\nimport {\n getCacheSignal,\n getDraftModeProviderForCacheScope,\n workUnitAsyncStorage,\n} from '../../app-render/work-unit-async-storage.external'\nimport {\n CachedRouteKind,\n IncrementalCacheKind,\n type CachedFetchData,\n} from '../../response-cache'\nimport type {\n UnstableCacheStore,\n WorkUnitStore,\n} from '../../app-render/work-unit-async-storage.external'\n\ntype Callback = (...args: any[]) => Promise<any>\n\nlet noStoreFetchIdx = 0\n\nasync function cacheNewResult<T>(\n result: T,\n incrementalCache: IncrementalCache,\n cacheKey: string,\n tags: string[],\n revalidate: number | false | undefined,\n fetchIdx: number,\n fetchUrl: string\n): Promise<unknown> {\n await incrementalCache.set(\n cacheKey,\n {\n kind: CachedRouteKind.FETCH,\n data: {\n headers: {},\n // TODO: handle non-JSON values?\n body: JSON.stringify(result),\n status: 200,\n url: '',\n } satisfies CachedFetchData,\n revalidate: typeof revalidate !== 'number' ? CACHE_ONE_YEAR : revalidate,\n },\n { fetchCache: true, tags, fetchIdx, fetchUrl }\n )\n return\n}\n\n/**\n * This function allows you to cache the results of expensive operations, like database queries, and reuse them across multiple requests.\n *\n * Read more: [Next.js Docs: `unstable_cache`](https://nextjs.org/docs/app/api-reference/functions/unstable_cache)\n */\nexport function unstable_cache<T extends Callback>(\n cb: T,\n keyParts?: string[],\n options: {\n /**\n * The revalidation interval in seconds.\n */\n revalidate?: number | false\n tags?: string[]\n } = {}\n): T {\n if (options.revalidate === 0) {\n throw new Error(\n `Invariant revalidate: 0 can not be passed to unstable_cache(), must be \"false\" or \"> 0\" ${cb.toString()}`\n )\n }\n\n // Validate the tags provided are valid\n const tags = options.tags\n ? validateTags(options.tags, `unstable_cache ${cb.toString()}`)\n : []\n\n // Validate the revalidate options\n validateRevalidate(\n options.revalidate,\n `unstable_cache ${cb.name || cb.toString()}`\n )\n\n // Stash the fixed part of the key at construction time. The invocation key will combine\n // the fixed key with the arguments when actually called\n // @TODO if cb.toString() is long we should hash it\n // @TODO come up with a collision-free way to combine keyParts\n // @TODO consider validating the keyParts are all strings. TS can't provide runtime guarantees\n // and the error produced by accidentally using something that cannot be safely coerced is likely\n // hard to debug\n const fixedKey = `${cb.toString()}-${\n Array.isArray(keyParts) && keyParts.join(',')\n }`\n\n const cachedCb = async (...args: any[]) => {\n const workStore = workAsyncStorage.getStore()\n const workUnitStore = workUnitAsyncStorage.getStore()\n\n // We must be able to find the incremental cache otherwise we throw\n const maybeIncrementalCache:\n | import('../../lib/incremental-cache').IncrementalCache\n | undefined =\n workStore?.incrementalCache || (globalThis as any).__incrementalCache\n\n if (!maybeIncrementalCache) {\n throw new Error(\n `Invariant: incrementalCache missing in unstable_cache ${cb.toString()}`\n )\n }\n const incrementalCache = maybeIncrementalCache\n\n const cacheSignal = workUnitStore ? getCacheSignal(workUnitStore) : null\n if (cacheSignal) {\n cacheSignal.beginRead()\n }\n try {\n // If there's no request store, we aren't in a request (or we're not in\n // app router) and if there's no static generation store, we aren't in app\n // router. Default to an empty pathname and search params when there's no\n // request store or static generation store available.\n const fetchUrlPrefix =\n workStore && workUnitStore\n ? getFetchUrlPrefix(workStore, workUnitStore)\n : ''\n\n // Construct the complete cache key for this function invocation\n // @TODO stringify is likely not safe here. We will coerce undefined to null which will make\n // the keyspace smaller than the execution space\n const invocationKey = `${fixedKey}-${JSON.stringify(args)}`\n const cacheKey = await incrementalCache.generateCacheKey(invocationKey)\n // $urlWithPath,$sortedQueryStringKeys,$hashOfEveryThingElse\n const fetchUrl = `unstable_cache ${fetchUrlPrefix} ${cb.name ? ` ${cb.name}` : cacheKey}`\n const fetchIdx =\n (workStore ? workStore.nextFetchId : noStoreFetchIdx) ?? 1\n\n const implicitTags = workUnitStore?.implicitTags\n\n const innerCacheStore: UnstableCacheStore = {\n type: 'unstable-cache',\n phase: 'render',\n implicitTags,\n draftMode:\n workUnitStore &&\n workStore &&\n getDraftModeProviderForCacheScope(workStore, workUnitStore),\n }\n\n if (workStore) {\n workStore.nextFetchId = fetchIdx + 1\n\n // We are in an App Router context. We try to return the cached entry if it exists and is valid\n // If the entry is fresh we return it. If the entry is stale we return it but revalidate the entry in\n // the background. If the entry is missing or invalid we generate a new entry and return it.\n\n let isNestedUnstableCache = false\n\n if (workUnitStore) {\n switch (workUnitStore.type) {\n case 'cache':\n case 'private-cache':\n case 'prerender':\n case 'prerender-runtime':\n case 'prerender-ppr':\n case 'prerender-legacy':\n // We update the store's revalidate property if the option.revalidate is a higher precedence\n // options.revalidate === undefined doesn't affect timing.\n // options.revalidate === false doesn't shrink timing. it stays at the maximum.\n if (typeof options.revalidate === 'number') {\n if (workUnitStore.revalidate < options.revalidate) {\n // The store is already revalidating on a shorter time interval, leave it alone\n } else {\n workUnitStore.revalidate = options.revalidate\n }\n }\n\n // We need to accumulate the tags for this invocation within the store\n const collectedTags = workUnitStore.tags\n if (collectedTags === null) {\n workUnitStore.tags = tags.slice()\n } else {\n for (const tag of tags) {\n // @TODO refactor tags to be a set to avoid this O(n) lookup\n if (!collectedTags.includes(tag)) {\n collectedTags.push(tag)\n }\n }\n }\n break\n case 'unstable-cache':\n isNestedUnstableCache = true\n break\n case 'prerender-client':\n case 'request':\n break\n default:\n workUnitStore satisfies never\n }\n }\n\n if (\n // when we are nested inside of other unstable_cache's\n // we should bypass cache similar to fetches\n !isNestedUnstableCache &&\n workStore.fetchCache !== 'force-no-store' &&\n !workStore.isOnDemandRevalidate &&\n !incrementalCache.isOnDemandRevalidate &&\n !workStore.isDraftMode\n ) {\n // We attempt to get the current cache entry from the incremental cache.\n const cacheEntry = await incrementalCache.get(cacheKey, {\n kind: IncrementalCacheKind.FETCH,\n revalidate: options.revalidate,\n tags,\n softTags: implicitTags?.tags,\n fetchIdx,\n fetchUrl,\n })\n\n if (cacheEntry && cacheEntry.value) {\n // The entry exists and has a value\n if (cacheEntry.value.kind !== CachedRouteKind.FETCH) {\n // The entry is invalid and we need a special warning\n // @TODO why do we warn this way? Should this just be an error? How are these errors surfaced\n // so bugs can be reported\n // @TODO the invocation key can have sensitive data in it. we should not log this entire object\n console.error(\n `Invariant invalid cacheEntry returned for ${invocationKey}`\n )\n // will fall through to generating a new cache entry below\n } else {\n // We have a valid cache entry so we will be returning it. We also check to see if we need\n // to background revalidate it by checking if it is stale.\n const cachedResponse =\n cacheEntry.value.data.body !== undefined\n ? JSON.parse(cacheEntry.value.data.body)\n : undefined\n if (cacheEntry.isStale) {\n // In App Router we return the stale result and revalidate in the background\n if (!workStore.pendingRevalidates) {\n workStore.pendingRevalidates = {}\n }\n\n // We run the cache function asynchronously and save the result when it completes\n workStore.pendingRevalidates[invocationKey] =\n workUnitAsyncStorage\n .run(innerCacheStore, cb, ...args)\n .then((result) => {\n return cacheNewResult(\n result,\n incrementalCache,\n cacheKey,\n tags,\n options.revalidate,\n fetchIdx,\n fetchUrl\n )\n })\n // @TODO This error handling seems wrong. We swallow the error?\n .catch((err) =>\n console.error(\n `revalidating cache with key: ${invocationKey}`,\n err\n )\n )\n }\n // We had a valid cache entry so we return it here\n return cachedResponse\n }\n }\n }\n\n // If we got this far then we had an invalid cache entry and need to generate a new one\n const result = await workUnitAsyncStorage.run(\n innerCacheStore,\n cb,\n ...args\n )\n\n if (!workStore.isDraftMode) {\n if (!workStore.pendingRevalidates) {\n workStore.pendingRevalidates = {}\n }\n\n // We need to push the cache result promise to pending\n // revalidates otherwise it won't be awaited and is just\n // dangling\n workStore.pendingRevalidates[invocationKey] = cacheNewResult(\n result,\n incrementalCache,\n cacheKey,\n tags,\n options.revalidate,\n fetchIdx,\n fetchUrl\n )\n }\n\n return result\n } else {\n noStoreFetchIdx += 1\n // We are in Pages Router or were called outside of a render. We don't have a store\n // so we just call the callback directly when it needs to run.\n // If the entry is fresh we return it. If the entry is stale we return it but revalidate the entry in\n // the background. If the entry is missing or invalid we generate a new entry and return it.\n\n if (!incrementalCache.isOnDemandRevalidate) {\n // We aren't doing an on demand revalidation so we check use the cache if valid\n const cacheEntry = await incrementalCache.get(cacheKey, {\n kind: IncrementalCacheKind.FETCH,\n revalidate: options.revalidate,\n tags,\n fetchIdx,\n fetchUrl,\n softTags: implicitTags?.tags,\n })\n\n if (cacheEntry && cacheEntry.value) {\n // The entry exists and has a value\n if (cacheEntry.value.kind !== CachedRouteKind.FETCH) {\n // The entry is invalid and we need a special warning\n // @TODO why do we warn this way? Should this just be an error? How are these errors surfaced\n // so bugs can be reported\n console.error(\n `Invariant invalid cacheEntry returned for ${invocationKey}`\n )\n // will fall through to generating a new cache entry below\n } else if (!cacheEntry.isStale) {\n // We have a valid cache entry and it is fresh so we return it\n return cacheEntry.value.data.body !== undefined\n ? JSON.parse(cacheEntry.value.data.body)\n : undefined\n }\n }\n }\n\n // If we got this far then we had an invalid cache entry and need to generate a new one\n const result = await workUnitAsyncStorage.run(\n innerCacheStore,\n cb,\n ...args\n )\n\n // we need to wait setting the new cache result here as\n // we don't have pending revalidates on workStore to\n // push to and we can't have a dangling promise\n await cacheNewResult(\n result,\n incrementalCache,\n cacheKey,\n tags,\n options.revalidate,\n fetchIdx,\n fetchUrl\n )\n return result\n }\n } finally {\n if (cacheSignal) {\n cacheSignal.endRead()\n }\n }\n }\n // TODO: once AsyncLocalStorage.run() returns the correct types this override will no longer be necessary\n return cachedCb as unknown as T\n}\n\nfunction getFetchUrlPrefix(\n workStore: WorkStore,\n workUnitStore: WorkUnitStore\n): string {\n switch (workUnitStore.type) {\n case 'request':\n const pathname = workUnitStore.url.pathname\n const searchParams = new URLSearchParams(workUnitStore.url.search)\n\n const sortedSearch = [...searchParams.keys()]\n .sort((a, b) => a.localeCompare(b))\n .map((key) => `${key}=${searchParams.get(key)}`)\n .join('&')\n\n return `${pathname}${sortedSearch.length ? '?' : ''}${sortedSearch}`\n case 'prerender':\n case 'prerender-client':\n case 'prerender-runtime':\n case 'prerender-ppr':\n case 'prerender-legacy':\n case 'cache':\n case 'private-cache':\n case 'unstable-cache':\n return workStore.route\n default:\n return workUnitStore satisfies never\n }\n}\n"],"names":["CACHE_ONE_YEAR","validateRevalidate","validateTags","workAsyncStorage","getCacheSignal","getDraftModeProviderForCacheScope","workUnitAsyncStorage","CachedRouteKind","IncrementalCacheKind","noStoreFetchIdx","cacheNewResult","result","incrementalCache","cacheKey","tags","revalidate","fetchIdx","fetchUrl","set","kind","FETCH","data","headers","body","JSON","stringify","status","url","fetchCache","unstable_cache","cb","keyParts","options","Error","toString","name","fixedKey","Array","isArray","join","cachedCb","args","workStore","getStore","workUnitStore","maybeIncrementalCache","globalThis","__incrementalCache","cacheSignal","beginRead","fetchUrlPrefix","getFetchUrlPrefix","invocationKey","generateCacheKey","nextFetchId","implicitTags","innerCacheStore","type","phase","draftMode","isNestedUnstableCache","collectedTags","slice","tag","includes","push","isOnDemandRevalidate","isDraftMode","cacheEntry","get","softTags","value","console","error","cachedResponse","undefined","parse","isStale","pendingRevalidates","run","then","catch","err","endRead","pathname","searchParams","URLSearchParams","search","sortedSearch","keys","sort","a","b","localeCompare","map","key","length","route"],"mappings":"AAEA,SAASA,cAAc,QAAQ,yBAAwB;AACvD,SAASC,kBAAkB,EAAEC,YAAY,QAAQ,wBAAuB;AACxE,SACEC,gBAAgB,QAEX,+CAA8C;AACrD,SACEC,cAAc,EACdC,iCAAiC,EACjCC,oBAAoB,QACf,oDAAmD;AAC1D,SACEC,eAAe,EACfC,oBAAoB,QAEf,uBAAsB;AAQ7B,IAAIC,kBAAkB;AAEtB,eAAeC,eACbC,MAAS,EACTC,gBAAkC,EAClCC,QAAgB,EAChBC,IAAc,EACdC,UAAsC,EACtCC,QAAgB,EAChBC,QAAgB;IAEhB,MAAML,iBAAiBM,GAAG,CACxBL,UACA;QACEM,MAAMZ,gBAAgBa,KAAK;QAC3BC,MAAM;YACJC,SAAS,CAAC;YACV,gCAAgC;YAChCC,MAAMC,KAAKC,SAAS,CAACd;YACrBe,QAAQ;YACRC,KAAK;QACP;QACAZ,YAAY,OAAOA,eAAe,WAAWf,iBAAiBe;IAChE,GACA;QAAEa,YAAY;QAAMd;QAAME;QAAUC;IAAS;IAE/C;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASY,eACdC,EAAK,EACLC,QAAm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KAAK;QACL,KAAK;QACL,KAAK;YACH,OAAO9C,UAAUuD,KAAK;QACxB;YACE,OAAOrD;IACX;AACF","ignoreList":[0]}
|
1
|
+
{"version":3,"sources":["../../../../src/server/web/spec-extension/unstable-cache.ts"],"sourcesContent":["import type { IncrementalCache } from '../../lib/incremental-cache'\n\nimport { CACHE_ONE_YEAR } from '../../../lib/constants'\nimport { validateRevalidate, validateTags } from '../../lib/patch-fetch'\nimport {\n workAsyncStorage,\n type WorkStore,\n} from '../../app-render/work-async-storage.external'\nimport {\n getCacheSignal,\n getDraftModeProviderForCacheScope,\n workUnitAsyncStorage,\n} from '../../app-render/work-unit-async-storage.external'\nimport {\n CachedRouteKind,\n IncrementalCacheKind,\n type CachedFetchData,\n} from '../../response-cache'\nimport type {\n UnstableCacheStore,\n WorkUnitStore,\n} from '../../app-render/work-unit-async-storage.external'\n\ntype Callback = (...args: any[]) => Promise<any>\n\nlet noStoreFetchIdx = 0\n\nasync function cacheNewResult<T>(\n result: T,\n incrementalCache: IncrementalCache,\n cacheKey: string,\n tags: string[],\n revalidate: number | false | undefined,\n fetchIdx: number,\n fetchUrl: string\n): Promise<unknown> {\n await incrementalCache.set(\n cacheKey,\n {\n kind: CachedRouteKind.FETCH,\n data: {\n headers: {},\n // TODO: handle non-JSON values?\n body: JSON.stringify(result),\n status: 200,\n url: '',\n } satisfies CachedFetchData,\n revalidate: typeof revalidate !== 'number' ? CACHE_ONE_YEAR : revalidate,\n },\n { fetchCache: true, tags, fetchIdx, fetchUrl }\n )\n return\n}\n\n/**\n * This function allows you to cache the results of expensive operations, like database queries, and reuse them across multiple requests.\n *\n * Read more: [Next.js Docs: `unstable_cache`](https://nextjs.org/docs/app/api-reference/functions/unstable_cache)\n */\nexport function unstable_cache<T extends Callback>(\n cb: T,\n keyParts?: string[],\n options: {\n /**\n * The revalidation interval in seconds.\n */\n revalidate?: number | false\n tags?: string[]\n } = {}\n): T {\n if (options.revalidate === 0) {\n throw new Error(\n `Invariant revalidate: 0 can not be passed to unstable_cache(), must be \"false\" or \"> 0\" ${cb.toString()}`\n )\n }\n\n // Validate the tags provided are valid\n const tags = options.tags\n ? validateTags(options.tags, `unstable_cache ${cb.toString()}`)\n : []\n\n // Validate the revalidate options\n validateRevalidate(\n options.revalidate,\n `unstable_cache ${cb.name || cb.toString()}`\n )\n\n // Stash the fixed part of the key at construction time. The invocation key will combine\n // the fixed key with the arguments when actually called\n // @TODO if cb.toString() is long we should hash it\n // @TODO come up with a collision-free way to combine keyParts\n // @TODO consider validating the keyParts are all strings. TS can't provide runtime guarantees\n // and the error produced by accidentally using something that cannot be safely coerced is likely\n // hard to debug\n const fixedKey = `${cb.toString()}-${\n Array.isArray(keyParts) && keyParts.join(',')\n }`\n\n const cachedCb = async (...args: any[]) => {\n const workStore = workAsyncStorage.getStore()\n const workUnitStore = workUnitAsyncStorage.getStore()\n\n // We must be able to find the incremental cache otherwise we throw\n const maybeIncrementalCache:\n | import('../../lib/incremental-cache').IncrementalCache\n | undefined =\n workStore?.incrementalCache || (globalThis as any).__incrementalCache\n\n if (!maybeIncrementalCache) {\n throw new Error(\n `Invariant: incrementalCache missing in unstable_cache ${cb.toString()}`\n )\n }\n const incrementalCache = maybeIncrementalCache\n\n const cacheSignal = workUnitStore ? getCacheSignal(workUnitStore) : null\n if (cacheSignal) {\n cacheSignal.beginRead()\n }\n try {\n // If there's no request store, we aren't in a request (or we're not in\n // app router) and if there's no static generation store, we aren't in app\n // router. Default to an empty pathname and search params when there's no\n // request store or static generation store available.\n const fetchUrlPrefix =\n workStore && workUnitStore\n ? getFetchUrlPrefix(workStore, workUnitStore)\n : ''\n\n // Construct the complete cache key for this function invocation\n // @TODO stringify is likely not safe here. We will coerce undefined to null which will make\n // the keyspace smaller than the execution space\n const invocationKey = `${fixedKey}-${JSON.stringify(args)}`\n const cacheKey = await incrementalCache.generateCacheKey(invocationKey)\n // $urlWithPath,$sortedQueryStringKeys,$hashOfEveryThingElse\n const fetchUrl = `unstable_cache ${fetchUrlPrefix} ${cb.name ? ` ${cb.name}` : cacheKey}`\n const fetchIdx =\n (workStore ? workStore.nextFetchId : noStoreFetchIdx) ?? 1\n\n const implicitTags = workUnitStore?.implicitTags\n\n const innerCacheStore: UnstableCacheStore = {\n type: 'unstable-cache',\n phase: 'render',\n implicitTags,\n draftMode:\n workUnitStore &&\n workStore &&\n getDraftModeProviderForCacheScope(workStore, workUnitStore),\n }\n\n if (workStore) {\n workStore.nextFetchId = fetchIdx + 1\n\n // We are in an App Router context. We try to return the cached entry if it exists and is valid\n // If the entry is fresh we return it. If the entry is stale we return it but revalidate the entry in\n // the background. If the entry is missing or invalid we generate a new entry and return it.\n\n let isNestedUnstableCache = false\n\n if (workUnitStore) {\n switch (workUnitStore.type) {\n case 'cache':\n case 'private-cache':\n case 'prerender':\n case 'prerender-runtime':\n case 'prerender-ppr':\n case 'prerender-legacy':\n // We update the store's revalidate property if the option.revalidate is a higher precedence\n // options.revalidate === undefined doesn't affect timing.\n // options.revalidate === false doesn't shrink timing. it stays at the maximum.\n if (typeof options.revalidate === 'number') {\n if (workUnitStore.revalidate < options.revalidate) {\n // The store is already revalidating on a shorter time interval, leave it alone\n } else {\n workUnitStore.revalidate = options.revalidate\n }\n }\n\n // We need to accumulate the tags for this invocation within the store\n const collectedTags = workUnitStore.tags\n if (collectedTags === null) {\n workUnitStore.tags = tags.slice()\n } else {\n for (const tag of tags) {\n // @TODO refactor tags to be a set to avoid this O(n) lookup\n if (!collectedTags.includes(tag)) {\n collectedTags.push(tag)\n }\n }\n }\n break\n case 'unstable-cache':\n isNestedUnstableCache = true\n break\n case 'prerender-client':\n case 'request':\n break\n default:\n workUnitStore satisfies never\n }\n }\n\n if (\n // when we are nested inside of other unstable_cache's\n // we should bypass cache similar to fetches\n !isNestedUnstableCache &&\n workStore.fetchCache !== 'force-no-store' &&\n !workStore.isOnDemandRevalidate &&\n !incrementalCache.isOnDemandRevalidate &&\n !workStore.isDraftMode\n ) {\n // We attempt to get the current cache entry from the incremental cache.\n const cacheEntry = await incrementalCache.get(cacheKey, {\n kind: IncrementalCacheKind.FETCH,\n revalidate: options.revalidate,\n tags,\n softTags: implicitTags?.tags,\n fetchIdx,\n fetchUrl,\n })\n\n if (cacheEntry && cacheEntry.value) {\n // The entry exists and has a value\n if (cacheEntry.value.kind !== CachedRouteKind.FETCH) {\n // The entry is invalid and we need a special warning\n // @TODO why do we warn this way? Should this just be an error? How are these errors surfaced\n // so bugs can be reported\n // @TODO the invocation key can have sensitive data in it. we should not log this entire object\n console.error(\n `Invariant invalid cacheEntry returned for ${invocationKey}`\n )\n // will fall through to generating a new cache entry below\n } else {\n // We have a valid cache entry so we will be returning it. We also check to see if we need\n // to background revalidate it by checking if it is stale.\n const cachedResponse =\n cacheEntry.value.data.body !== undefined\n ? JSON.parse(cacheEntry.value.data.body)\n : undefined\n\n if (cacheEntry.isStale) {\n if (!workStore.pendingRevalidates) {\n workStore.pendingRevalidates = {}\n }\n\n // Check if there's already a pending revalidation to avoid duplicate work\n if (!workStore.pendingRevalidates[invocationKey]) {\n // Create the revalidation promise\n const revalidationPromise = workUnitAsyncStorage\n .run(innerCacheStore, cb, ...args)\n .then(async (result) => {\n await cacheNewResult(\n result,\n incrementalCache,\n cacheKey,\n tags,\n options.revalidate,\n fetchIdx,\n fetchUrl\n )\n return result\n })\n .catch((err) => {\n // @TODO This error handling seems wrong. We swallow the error?\n console.error(\n `revalidating cache with key: ${invocationKey}`,\n err\n )\n // Return the stale value on error for foreground revalidation\n return cachedResponse\n })\n\n // Attach the empty catch here so we don't get a \"unhandled promise\n // rejection\" warning. (Behavior is matched with patch-fetch)\n if (workStore.isRevalidate) {\n revalidationPromise.catch(() => {})\n }\n\n workStore.pendingRevalidates[invocationKey] =\n revalidationPromise\n }\n\n // Check if we need to do foreground revalidation\n if (workStore.isRevalidate) {\n // When the page is revalidating and the cache entry is stale,\n // we need to wait for fresh data (blocking revalidate)\n return workStore.pendingRevalidates[invocationKey]\n }\n // Otherwise, we're doing background revalidation - return stale immediately\n }\n\n // We had a valid cache entry so we return it here\n return cachedResponse\n }\n }\n }\n\n // If we got this far then we had an invalid cache entry and need to generate a new one\n const result = await workUnitAsyncStorage.run(\n innerCacheStore,\n cb,\n ...args\n )\n\n if (!workStore.isDraftMode) {\n if (!workStore.pendingRevalidates) {\n workStore.pendingRevalidates = {}\n }\n\n // We need to push the cache result promise to pending\n // revalidates otherwise it won't be awaited and is just\n // dangling\n workStore.pendingRevalidates[invocationKey] = cacheNewResult(\n result,\n incrementalCache,\n cacheKey,\n tags,\n options.revalidate,\n fetchIdx,\n fetchUrl\n )\n }\n\n return result\n } else {\n noStoreFetchIdx += 1\n // We are in Pages Router or were called outside of a render. We don't have a store\n // so we just call the callback directly when it needs to run.\n // If the entry is fresh we return it. If the entry is stale we return it but revalidate the entry in\n // the background. If the entry is missing or invalid we generate a new entry and return it.\n\n if (!incrementalCache.isOnDemandRevalidate) {\n // We aren't doing an on demand revalidation so we check use the cache if valid\n const cacheEntry = await incrementalCache.get(cacheKey, {\n kind: IncrementalCacheKind.FETCH,\n revalidate: options.revalidate,\n tags,\n fetchIdx,\n fetchUrl,\n softTags: implicitTags?.tags,\n })\n\n if (cacheEntry && cacheEntry.value) {\n // The entry exists and has a value\n if (cacheEntry.value.kind !== CachedRouteKind.FETCH) {\n // The entry is invalid and we need a special warning\n // @TODO why do we warn this way? Should this just be an error? How are these errors surfaced\n // so bugs can be reported\n console.error(\n `Invariant invalid cacheEntry returned for ${invocationKey}`\n )\n // will fall through to generating a new cache entry below\n } else if (!cacheEntry.isStale) {\n // We have a valid cache entry and it is fresh so we return it\n return cacheEntry.value.data.body !== undefined\n ? JSON.parse(cacheEntry.value.data.body)\n : undefined\n }\n }\n }\n\n // If we got this far then we had an invalid cache entry and need to generate a new one\n const result = await workUnitAsyncStorage.run(\n innerCacheStore,\n cb,\n ...args\n )\n\n // we need to wait setting the new cache result here as\n // we don't have pending revalidates on workStore to\n // push to and we can't have a dangling promise\n await cacheNewResult(\n result,\n incrementalCache,\n cacheKey,\n tags,\n options.revalidate,\n fetchIdx,\n fetchUrl\n )\n return result\n }\n } finally {\n if (cacheSignal) {\n cacheSignal.endRead()\n }\n }\n }\n // TODO: once AsyncLocalStorage.run() returns the correct types this override will no longer be necessary\n return cachedCb as unknown as T\n}\n\nfunction getFetchUrlPrefix(\n workStore: WorkStore,\n workUnitStore: WorkUnitStore\n): string {\n switch (workUnitStore.type) {\n case 'request':\n const pathname = workUnitStore.url.pathname\n const searchParams = new URLSearchParams(workUnitStore.url.search)\n\n const sortedSearch = [...searchParams.keys()]\n .sort((a, b) => a.localeCompare(b))\n .map((key) => `${key}=${searchParams.get(key)}`)\n .join('&')\n\n return `${pathname}${sortedSearch.length ? '?' : ''}${sortedSearch}`\n case 'prerender':\n case 'prerender-client':\n case 'prerender-runtime':\n case 'prerender-ppr':\n case 'prerender-legacy':\n case 'cache':\n case 'private-cache':\n case 'unstable-cache':\n return workStore.route\n default:\n return workUnitStore satisfies never\n }\n}\n"],"names":["CACHE_ONE_YEAR","validateRevalidate","validateTags","workAsyncStorage","getCacheSignal","getDraftModeProviderForCacheScope","workUnitAsyncStorage","CachedRouteKind","IncrementalCacheKind","noStoreFetchIdx","cacheNewResult","result","incrementalCache","cacheKey","tags","revalidate","fetchIdx","fetchUrl","set","kind","FETCH","data","headers","body","JSON","stringify","status","url","fetchCache","unstable_cache","cb","keyParts","options","Error","toString","name","fixedKey","Array","isArray","join","cachedCb","args","workStore","getStore","workUnitStore","maybeIncrementalCache","globalThis","__incrementalCache","cacheSignal","beginRead","fetchUrlPrefix","getFetchUrlPrefix","invocationKey","generateCacheKey","nextFetchId","implicitTags","innerCacheStore","type","phase","draftMode","isNestedUnstableCache","collectedTags","slice","tag","includes","push","isOnDemandRevalidate","isDraftMode","cacheEntry","get","softTags","value","console","error","cachedResponse","undefined","parse","isStale","pendingRevalidates","revalidationPromise","run","then","catch","err","isRevalidate","endRead","pathname","searchParams","URLSearchParams","search","sortedSearch","keys","sort","a","b","localeComp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reList":[0]}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
export function isStableBuild() {
|
2
2
|
var _process_env___NEXT_VERSION;
|
3
|
-
return !((_process_env___NEXT_VERSION = "15.6.0-canary.
|
3
|
+
return !((_process_env___NEXT_VERSION = "15.6.0-canary.8") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
|
4
4
|
}
|
5
5
|
export class CanaryOnlyError extends Error {
|
6
6
|
constructor(arg){
|
@@ -221,7 +221,6 @@ export default abstract class Server<ServerOptions extends Options = Options, Se
|
|
221
221
|
* it's only fully used in dev
|
222
222
|
*/
|
223
223
|
constructor(options: ServerOptions);
|
224
|
-
protected reloadMatchers(): Promise<void>;
|
225
224
|
private handleRSCRequest;
|
226
225
|
private handleNextDataRequest;
|
227
226
|
protected handleNextImageRequest: RouteHandler<ServerRequest, ServerResponse>;
|
@@ -422,9 +422,6 @@ class Server {
|
|
422
422
|
dev
|
423
423
|
});
|
424
424
|
}
|
425
|
-
reloadMatchers() {
|
426
|
-
return this.matchers.reload();
|
427
|
-
}
|
428
425
|
getRouteMatchers() {
|
429
426
|
// Create a new manifest loader that get's the manifests from the server.
|
430
427
|
const manifestLoader = new _servermanifestloader.ServerManifestLoader((name)=>{
|