-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix loading issue when navigating to page with async metadata (#61687)
### What Client-side transitioning to a page that triggered a loading boundary with async metadata would cause the transition to stall, potentially getting stuck in a refetch loop. ### Why In layout-router, we trigger a "lazy fetch" when we encounter a segment that we don't have cache nodes for. This calls out to the server and suspends until the data fetch is resolved, and applied to the router tree. However after suspending but before updating the client router, we set `childNode.lazyData` to null. When we unsuspend from the server patch action, `childNode.rsc` might still be missing and clearing `lazyData` means we've blown away the reference to the fetch we already had pending, triggering a refetch loop. ### How This removes the logic that mutates the cache node in render, as this is not concurrent safe, and doesn't appear to be needed for anything. Fixes #61117 Closes NEXT-2361 --------- Co-authored-by: Jiachi Liu <inbox@huozhi.im>
- Loading branch information
Showing
6 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/navigation/app/metadata-await-promise/nested/loading.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Loading() { | ||
return <div id="loading">Loading</div> | ||
} |
18 changes: 18 additions & 0 deletions
18
test/e2e/app-dir/navigation/app/metadata-await-promise/nested/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
|
||
// ensure this page is dynamically rendered so we always trigger a loading state | ||
export const dynamic = 'force-dynamic' | ||
|
||
export default function page() { | ||
return <div id="page-content">Content</div> | ||
} | ||
|
||
async function getTitle() { | ||
return await new Promise((resolve) => | ||
setTimeout(() => resolve('Async Title'), 1000) | ||
) | ||
} | ||
|
||
export async function generateMetadata() { | ||
return { title: await getTitle() } | ||
} |
9 changes: 9 additions & 0 deletions
9
test/e2e/app-dir/navigation/app/metadata-await-promise/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Link from 'next/link' | ||
|
||
export default function page() { | ||
return ( | ||
<div> | ||
<Link href="/metadata-await-promise/nested">Link to nested</Link> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters