Unverified Commit d7c77653 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

[backport]: Ensure app-page reports stale ISR revalidation errors via…

[backport]: Ensure app-page reports stale ISR revalidation errors via onRequestError (#92282) (#92519)

Backports:
- #92282
parent c573e8c4
...@@ -998,6 +998,7 @@ export async function handler( ...@@ -998,6 +998,7 @@ export async function handler(
const isProduction = routeModule.isDev === false const isProduction = routeModule.isDev === false
const didRespond = hasResolved || res.writableEnded const didRespond = hasResolved || res.writableEnded
try {
// skip on-demand revalidate if cache is not present and // skip on-demand revalidate if cache is not present and
// revalidate-if-generated is set // revalidate-if-generated is set
if ( if (
...@@ -1235,13 +1236,13 @@ export async function handler( ...@@ -1235,13 +1236,13 @@ export async function handler(
? minimalPostponed ? minimalPostponed
: undefined : undefined
if (
// If this is a dynamic RSC request or a server action request, we should // If this is a dynamic RSC request or a server action request, we should
// use the postponed data from the static render (if available). This // use the postponed data from the static render (if available). This
// ensures that we can utilize the resume data cache (RDC) from the static // ensures that we can utilize the resume data cache (RDC) from the static
// render to ensure that the data is consistent between the static and // render to ensure that the data is consistent between the static and
// dynamic renders (for navigations) or when re-rendering after a server // dynamic renders (for navigations) or when re-rendering after a server
// action. // action.
if (
// Only enable RDC for Navigations if the feature is enabled. // Only enable RDC for Navigations if the feature is enabled.
supportsRDCForNavigations && supportsRDCForNavigations &&
process.env.NEXT_RUNTIME !== 'edge' && process.env.NEXT_RUNTIME !== 'edge' &&
...@@ -1380,6 +1381,29 @@ export async function handler( ...@@ -1380,6 +1381,29 @@ export async function handler(
fallbackRouteParams, fallbackRouteParams,
forceStaticRender, forceStaticRender,
}) })
} catch (err) {
// if this is a background revalidate we need to report
// the request error here as it won't be bubbled
if (previousIncrementalCacheEntry?.isStale) {
const silenceLog = false
await routeModule.onRequestError(
req,
err,
{
routerKind: 'App Router',
routePath: srcPage,
routeType: 'render',
revalidateReason: getRevalidateReason({
isStaticGeneration: isSSG,
isOnDemandRevalidate,
}),
},
silenceLog,
routerServerContext
)
}
throw err
}
} }
const handleResponse = async (span?: Span): Promise<null | void> => { const handleResponse = async (span?: Span): Promise<null | void> => {
......
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