Skip to content

Ensure app-page reports stale ISR revalidation errors via onRequestError#92282

Merged
ztanner merged 1 commit intocanaryfrom
04-02-ensure_app-page_reports_stale_isr_revalidation_errors_via_onrequesterror
Apr 3, 2026
Merged

Ensure app-page reports stale ISR revalidation errors via onRequestError#92282
ztanner merged 1 commit intocanaryfrom
04-02-ensure_app-page_reports_stale_isr_revalidation_errors_via_onrequesterror

Conversation

@ztanner
Copy link
Copy Markdown
Member

@ztanner ztanner commented Apr 2, 2026

Note: the change is mostly whitespace. Recommend reviewing w/o whitespace here.

For App Router pages using time-based ISR, a stale cached response can be returned before background revalidation finishes. If that background revalidation later throws, the error does not bubble back through the normal top-level app-page request catch. Instead, the response cache has already resolved the request and later logs the failure internally.

When an error happens while rendering an app router page, and the entry is stale, we now explicitly await routeModule.onRequestError(...) before rethrowing.

This copies similar handling in pages router:

// if this is a background revalidate we need to report
// the request error here as it won't be bubbled
if (previousCacheEntry?.isStale) {
const silenceLog = false
await routeModule.onRequestError(
req,
err,
{
routerKind: 'Pages Router',
routePath: srcPage,
routeType: 'render',
revalidateReason: getRevalidateReason({
isStaticGeneration: hasStaticProps,
isOnDemandRevalidate,
}),
},
silenceLog,
routerServerContext
)
}
throw err
}
}

and route handlers:

// if this is a background revalidate we need to report
// the request error here as it won't be bubbled
if (previousCacheEntry?.isStale) {

Copy link
Copy Markdown
Member Author

ztanner commented Apr 2, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ztanner ztanner marked this pull request as ready for review April 2, 2026 22:01
@ztanner ztanner requested a review from ijjk April 2, 2026 22:04
@nextjs-bot
Copy link
Copy Markdown
Collaborator

nextjs-bot commented Apr 2, 2026

Tests Passed

@ztanner ztanner merged commit 9cb2048 into canary Apr 3, 2026
428 of 450 checks passed
@ztanner ztanner deleted the 04-02-ensure_app-page_reports_stale_isr_revalidation_errors_via_onrequesterror branch April 3, 2026 16:04
eps1lon pushed a commit that referenced this pull request Apr 7, 2026
…ror (#92282)

Note: the change is mostly whitespace. Recommend reviewing w/o
whitespace
[here](https://github.com/vercel/next.js/pull/92282/changes?w=1).

For App Router pages using time-based ISR, a stale cached response can
be returned before background revalidation finishes. If that background
revalidation later throws, the error does not bubble back through the
normal top-level `app-page` request catch. Instead, the response cache
has already resolved the request and later logs the failure internally.

When an error happens while rendering an app router page, and the entry
is stale, we now explicitly await `routeModule.onRequestError(...)`
before rethrowing.

This copies similar handling in pages router:
https://github.com/vercel/next.js/blob/daca04d09bf9aaee9e1c63324166985b643e9844/packages/next/src/server/route-modules/pages/pages-handler.ts#L438-L460

and route handlers:

https://github.com/vercel/next.js/blob/daca04d09bf9aaee9e1c63324166985b643e9844/packages/next/src/build/templates/app-route.ts#L407-L409
eps1lon pushed a commit that referenced this pull request Apr 7, 2026
…ror (#92282)

Note: the change is mostly whitespace. Recommend reviewing w/o
whitespace
[here](https://github.com/vercel/next.js/pull/92282/changes?w=1).

For App Router pages using time-based ISR, a stale cached response can
be returned before background revalidation finishes. If that background
revalidation later throws, the error does not bubble back through the
normal top-level `app-page` request catch. Instead, the response cache
has already resolved the request and later logs the failure internally.

When an error happens while rendering an app router page, and the entry
is stale, we now explicitly await `routeModule.onRequestError(...)`
before rethrowing.

This copies similar handling in pages router:
https://github.com/vercel/next.js/blob/daca04d09bf9aaee9e1c63324166985b643e9844/packages/next/src/server/route-modules/pages/pages-handler.ts#L438-L460

and route handlers:

https://github.com/vercel/next.js/blob/daca04d09bf9aaee9e1c63324166985b643e9844/packages/next/src/build/templates/app-route.ts#L407-L409
ztanner added a commit that referenced this pull request Apr 8, 2026
…ror (#92282)

Note: the change is mostly whitespace. Recommend reviewing w/o
whitespace
[here](https://github.com/vercel/next.js/pull/92282/changes?w=1).

For App Router pages using time-based ISR, a stale cached response can
be returned before background revalidation finishes. If that background
revalidation later throws, the error does not bubble back through the
normal top-level `app-page` request catch. Instead, the response cache
has already resolved the request and later logs the failure internally.

When an error happens while rendering an app router page, and the entry
is stale, we now explicitly await `routeModule.onRequestError(...)`
before rethrowing.

This copies similar handling in pages router:
https://github.com/vercel/next.js/blob/daca04d09bf9aaee9e1c63324166985b643e9844/packages/next/src/server/route-modules/pages/pages-handler.ts#L438-L460

and route handlers:

https://github.com/vercel/next.js/blob/daca04d09bf9aaee9e1c63324166985b643e9844/packages/next/src/build/templates/app-route.ts#L407-L409
ztanner added a commit that referenced this pull request Apr 8, 2026
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants