-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Prefetching lazily generated param
Fixes an oversight in #72168 where the segment data was not correctly transferred from the render result to the cache entry in the case where a prerender is lazily generated after build. I also took the opportunity to remove one of the intermediate types used by the various layers that the segment data passes through. For some reason, in the original PR I made the type of `segmentData` on CachedAppPageValue an object while the corresponding type on AppPageRenderResultMetadata was a map. (I didn't really notice before because in the case where the entry is generated at built time, it gets written to disk then read back out, so there's some data conversion happening anyway.)
- Loading branch information
Showing
9 changed files
with
168 additions
and
33 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
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
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
14 changes: 14 additions & 0 deletions
14
test/e2e/app-dir/segment-cache/basic/app/lazily-generated-params/[param]/page.tsx
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,14 @@ | ||
import { Suspense } from 'react' | ||
|
||
async function Content({ params }) { | ||
const { param } = await params | ||
return <div id="target-page-with-lazily-generated-param">Param: {param}</div> | ||
} | ||
|
||
export default async function Target({ params }) { | ||
return ( | ||
<Suspense fallback="Loading..."> | ||
<Content params={params} /> | ||
</Suspense> | ||
) | ||
} |
22 changes: 22 additions & 0 deletions
22
test/e2e/app-dir/segment-cache/basic/app/lazily-generated-params/page.tsx
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,22 @@ | ||
import Link from 'next/link' | ||
|
||
// TODO: Once the appropriate API exists/is implemented, configure the param to | ||
// be statically generated on demand but not at build time (`dynamicParams = | ||
// true` isn't supported when `dynamicIO` is enabled.) For now this test case | ||
// seems to work without extra configuration but it might not in the future. | ||
|
||
export default function LazilyGeneratedParamsStartPage() { | ||
return ( | ||
<> | ||
<p> | ||
Demonstrates that we can prefetch param that is not generated at build | ||
time but is lazily generated on demand | ||
</p> | ||
<ul> | ||
<li> | ||
<Link href="/lazily-generated-params/some-param-value">Target</Link> | ||
</li> | ||
</ul> | ||
</> | ||
) | ||
} |
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