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

Preserve the existing dynamic error path

parent cf41e173
...@@ -639,17 +639,16 @@ export class AppRouteRouteModule extends RouteModule< ...@@ -639,17 +639,16 @@ 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 dynamicRequestAccess = dynamicTracking.dynamicAccesses.find( const hasDynamicRequestAccess = dynamicTracking.dynamicAccesses.some(
({ expression }) => ({ expression }) =>
expression.startsWith('nextUrl.') || expression.startsWith('nextUrl.') ||
expression.startsWith('request.') expression.startsWith('request.')
)?.expression )
if (prospectiveRenderIsDynamic || dynamicRequestAccess) { if (prospectiveRenderIsDynamic || hasDynamicRequestAccess) {
// 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 = const dynamicReason = getFirstDynamicReason(dynamicTracking)
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