mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This makes some critical modifications to the app render pipeline when PPR has been enabled for pages with segments defining: ```js export const dynamic = "force-dynamic" ``` Importantly, it no longer modifies the revalidation time to zero for those pages, and now falls back to the provided default revalidation time. When static render occurs, if the page being rendered has a segment config defining `dynamic === "force-dynamic"`, then it will postpone at the root of the component tree. This ensures that no render code is executed for the page, as the entirety of the tree will have postponed. This fixes the bug where the flight prefetch wasn't generated correctly as well.
23 lines
586 B
JavaScript
23 lines
586 B
JavaScript
const MAX_ATTEMPTS = 5
|
|
|
|
export const fetchRetry = async (url, init) => {
|
|
for (let i = 0; i < MAX_ATTEMPTS; i++) {
|
|
try {
|
|
return await fetch(url, init)
|
|
} catch (err) {
|
|
// FIXME: (PPR) this is a workaround until we have a way to detect postpone errors
|
|
// For PPR, we need to detect if this is a postpone error so we can
|
|
// re-throw it.
|
|
if (err.$$typeof === Symbol.for('react.postpone')) {
|
|
throw err
|
|
}
|
|
|
|
if (i === MAX_ATTEMPTS - 1) {
|
|
throw err
|
|
}
|
|
|
|
console.log(`Failed to fetch`, err, `retrying...`)
|
|
}
|
|
}
|
|
}
|