Files
Wyatt JohnsonandGitHub eab1fe8397 Enable PPR for dynamic = "force-dynamic" (#58779)
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.
2023-12-06 01:10:00 +00:00

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...`)
}
}
}