Unverified Commit cf41e173 authored by David Alexandru Ilie's avatar David Alexandru Ilie Committed by GitHub

Narrow caught request access detection

parent 0770f285
...@@ -639,11 +639,17 @@ export class AppRouteRouteModule extends RouteModule< ...@@ -639,11 +639,17 @@ export class AppRouteRouteModule extends RouteModule<
// The handler may catch the prerender interruption and resolve // The handler may catch the prerender interruption and resolve
// normally, but dynamic tracking still records the request access. // normally, but dynamic tracking still records the request access.
const dynamicReason = getFirstDynamicReason(dynamicTracking) const dynamicRequestAccess = dynamicTracking.dynamicAccesses.find(
({ expression }) =>
expression.startsWith('nextUrl.') ||
expression.startsWith('request.')
)?.expression
if (prospectiveRenderIsDynamic || dynamicReason) { if (prospectiveRenderIsDynamic || dynamicRequestAccess) {
// the route handler called an API which is always dynamic // the route handler called an API which is always dynamic
// there is no need to try again // there is no need to try again
const dynamicReason =
dynamicRequestAccess ?? getFirstDynamicReason(dynamicTracking)
if (dynamicReason) { if (dynamicReason) {
throw new DynamicServerError( throw new DynamicServerError(
`Route ${workStore.route} couldn't be rendered statically because it used \`${dynamicReason}\`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error` `Route ${workStore.route} couldn't be rendered statically because it used \`${dynamicReason}\`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment