Skip to content

Commit 0b8a8ee

Browse files
committed
fixes
1 parent 15cbe5d commit 0b8a8ee

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

packages/next/src/server/app-render/work-unit-async-storage.external.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export type RequestStore = {
4949
* to fill all caches.
5050
*/
5151
export type PrerenderStoreModern = {
52-
type: 'prerender',
52+
type: 'prerender'
5353
pathname: string | undefined
5454
/**
5555
* This is the AbortController passed to React. It can be used to abort the prerender
@@ -70,7 +70,7 @@ export type PrerenderStoreModern = {
7070
}
7171

7272
export type PrerenderStoreLegacy = {
73-
type: 'prerender-legacy',
73+
type: 'prerender-legacy'
7474
pathname: string | undefined
7575
}
7676

packages/next/src/server/route-modules/app-route/module.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ export class AppRouteRouteModule extends RouteModule<
299299
: undefined,
300300
}
301301

302+
const pathname =
303+
workUnitStore.type === 'request'
304+
? workUnitStore.url.pathname
305+
: workUnitStore.type === 'prerender' ||
306+
workUnitStore.type === 'prerender-legacy'
307+
? workUnitStore.pathname
308+
: undefined
309+
302310
let res: unknown
303311
try {
304312
if (isStaticGeneration && dynamicIOEnabled) {
@@ -323,9 +331,10 @@ export class AppRouteRouteModule extends RouteModule<
323331
let prospectiveRenderIsDynamic = false
324332
const cacheSignal = new CacheSignal()
325333
let dynamicTracking = createDynamicTrackingState(undefined)
334+
326335
const prospectiveRoutePrerenderStore: PrerenderStore = {
327336
type: 'prerender',
328-
pathname: requestStore.url.pathname,
337+
pathname,
329338
cacheSignal,
330339
// During prospective render we don't use a controller
331340
// because we need to let all caches fill.
@@ -393,7 +402,7 @@ export class AppRouteRouteModule extends RouteModule<
393402

394403
const finalRoutePrerenderStore: PrerenderStore = {
395404
type: 'prerender',
396-
pathname: requestStore.url.pathname,
405+
pathname,
397406
cacheSignal: null,
398407
controller,
399408
dynamicTracking,
@@ -457,7 +466,7 @@ export class AppRouteRouteModule extends RouteModule<
457466
res = await workUnitAsyncStorage.run(
458467
{
459468
type: 'prerender-legacy',
460-
pathname: requestStore.url.pathname,
469+
pathname,
461470
},
462471
handler,
463472
request,
@@ -517,7 +526,6 @@ export class AppRouteRouteModule extends RouteModule<
517526
])
518527

519528
addImplicitTags(workStore, workUnitStore)
520-
521529
;(context.renderOpts as any).fetchTags = workStore.tags?.join(',')
522530

523531
// It's possible cookies were set in the handler, so we need

packages/next/src/server/web/spec-extension/unstable-cache.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,11 @@ export function unstable_cache<T extends Callback>(
342342
type: 'unstable-cache',
343343
}
344344
// If we got this far then we had an invalid cache entry and need to generate a new one
345-
const result = await cacheAsyncStorage.run(innerCacheStore, cb, ...args)
345+
const result = await workUnitAsyncStorage.run(
346+
innerCacheStore,
347+
cb,
348+
...args
349+
)
346350
cacheNewResult(
347351
result,
348352
incrementalCache,

0 commit comments

Comments
 (0)