Unverified Commit 51e091d5 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix prerender tags when notFound is called (#74577)

This ensures we don't lose tags added to a page before `notFound()` is
called as otherwise a fetch on the page that has been revalidated won't
be able to be applied correctly if dropped from a `notFound()` call.
This was broken recently in the refactors of handling rendering in
app-render as it worked correctly in `v14`.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04V3E1UYNQ/p1736200963684869)

Closes https://linear.app/vercel/issue/ENET-1381
Closes https://linear.app/vercel/issue/NEXT-3946
Closes https://github.com/vercel/next.js/issues/73973
Closes https://github.com/vercel/next.js/issues/66540
parent 5a8d1171
...@@ -3833,7 +3833,7 @@ async function prerenderToStream( ...@@ -3833,7 +3833,7 @@ async function prerenderToStream(
revalidate: INFINITE_CACHE, revalidate: INFINITE_CACHE,
expire: INFINITE_CACHE, expire: INFINITE_CACHE,
stale: INFINITE_CACHE, stale: INFINITE_CACHE,
tags: [...implicitTags], tags: [...(prerenderStore?.tags || implicitTags)],
}) })
const errorRSCPayload = await workUnitAsyncStorage.run( const errorRSCPayload = await workUnitAsyncStorage.run(
prerenderLegacyStore, prerenderLegacyStore,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
import React from 'react'
import { notFound } from 'next/navigation'
export function generateStaticParams() {
return [
{
slug: 'first',
},
{
slug: 'second',
},
]
}
export default async function Page(props: {
params: Promise<{ slug: string }>
}) {
const params = await props.params
await fetch('https://next-data-api.vercel.app/api/random', {
next: {
tags: ['explicit-tag'],
},
})
if (
params.slug !== 'second' &&
process.env.NEXT_PHASE === 'phase-production-build'
) {
notFound()
}
return (
<>
<p>/prerendered-not-found/{params.slug}</p>
<p>{Date.now()}</p>
</>
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment