You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ppr: fail static generation if postponed & missing postpone data (#57786)
When postpone is caught by user code, this will cause PPR not to properly prerender the static parts and thus we need to fail the build. This also adds some messaging about how to fix the error.
Prior to this change, catching code that would normally trigger `postpone ` would silently fail, but the build outputs would be incorrect as there's no postpone data available.
Relands #57477 with additional tests & fixes
title: Understanding the postpone error triggered during static generation
3
+
---
4
+
5
+
## Why This Error Occurred
6
+
7
+
When Partial Prerendering (PPR) is enabled, using APIs that opt into Dynamic Rendering like `cookies`, `headers`, or `fetch` (such as with `cache: 'no-store'` or `revalidate: 0`) will cause Next.js to throw a special error to know which part of the page cannot be statically generated. If you catch this error, we will not be able to generate any static data, and your build will fail.
8
+
9
+
## Possible Ways to Fix It
10
+
11
+
To resolve this issue, ensure that you are not wrapping Next.js APIs that opt into dynamic rendering in a `try/catch` block.
12
+
13
+
If you do wrap these APIs in a try/catch, make sure you re-throw the original error so it can be caught by Next.
// a call to postpone was made but was caught and not detected by Next.js. We should fail the build immediately
1013
+
// as we won't be able to generate the static part
1014
+
warn('')
1015
+
error(
1016
+
`Postpone signal was caught while rendering ${urlPathname}. Check to see if you're try/catching a Next.js API such as headers / cookies, or a fetch with "no-store". Learn more: https://nextjs.org/docs/messages/ppr-postpone-errors`
1017
+
)
1018
+
1019
+
if(capturedErrors.length>0){
1020
+
warn(
1021
+
'The following error was thrown during build, and may help identify the source of the issue:'
1022
+
)
1023
+
1024
+
error(capturedErrors[0])
1025
+
}
1026
+
1027
+
thrownewMissingPostponeDataError(
1028
+
`An unexpected error occurred while prerendering ${urlPathname}. Please check the logs above for more details.`
1029
+
)
1030
+
}
1031
+
1006
1032
// if we encountered any unexpected errors during build
0 commit comments