mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
This is to fix an issue where these redirect side effects can be fired multiple times when the router reducer state changes. This block is still run when the router state updates, which can lead to superfluous attempts to redirect to a page. With these changes, we keep track of the page that is being redirected to. If a re-render occurs while that request is in flight, we don't trigger the side effects. [Slack x-ref](https://vercel.slack.com/archives/C04DUD7EB1B/p1694049914264839)
14 lines
318 B
JavaScript
14 lines
318 B
JavaScript
export default function Page() {
|
|
return 'Hello from slow page'
|
|
}
|
|
|
|
export async function getServerSideProps({ resolvedUrl }) {
|
|
if (!resolvedUrl.includes('?_rsc')) {
|
|
// only stall on the navigation, not prefetch
|
|
await new Promise((resolve) => setTimeout(resolve, 100000))
|
|
}
|
|
return {
|
|
props: {},
|
|
}
|
|
}
|