Skip to content

Commit 360cbf1

Browse files
committed
feat(app-router): improve fallback response handling for client param parsing
- Add conditional logic to use fallback responses when client param parsing is enabled - Allow fallback use for non-dynamic RSC requests when feature flag is active
1 parent 2514869 commit 360cbf1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/next/src/build/templates/app-page.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,17 @@ export async function handler(
697697
throw new NoFallbackError()
698698
}
699699

700-
let fallbackResponse: ResponseCacheEntry | null | undefined
701-
702-
if (isRoutePPREnabled && !isRSCRequest) {
700+
// When client param parsing is enabled, we can use the fallback
701+
// response if the request is not a dynamic RSC request because the
702+
// RSC data when this feature flag is enabled does not contain any
703+
// param references. Without this feature flag enabled, the RSC data
704+
// contains param references, and therefore we can't use the fallback.
705+
if (
706+
isRoutePPREnabled &&
707+
(nextConfig.experimental.clientParamParsing
708+
? !isDynamicRSCRequest
709+
: !isRSCRequest)
710+
) {
703711
const cacheKey =
704712
typeof prerenderInfo?.fallback === 'string'
705713
? prerenderInfo.fallback
@@ -709,7 +717,7 @@ export async function handler(
709717

710718
// We use the response cache here to handle the revalidation and
711719
// management of the fallback shell.
712-
fallbackResponse = await routeModule.handleResponse({
720+
const fallbackResponse = await routeModule.handleResponse({
713721
cacheKey,
714722
req,
715723
nextConfig,
@@ -747,6 +755,7 @@ export async function handler(
747755
}
748756
}
749757
}
758+
750759
// Only requests that aren't revalidating can be resumed. If we have the
751760
// minimal postponed data, then we should resume the render with it.
752761
const postponed =

0 commit comments

Comments
 (0)