Unverified Commit 6f6766a2 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix prerender tags when notFound is called (#74577) (#74607)

This backports #74577 which ensures we don't lose tags added to a page
before notFound() is called.
parent a46f27f5
......@@ -3777,7 +3777,7 @@ async function prerenderToStream(
revalidate: INFINITE_CACHE,
expire: INFINITE_CACHE,
stale: INFINITE_CACHE,
tags: [...implicitTags],
tags: [...(prerenderStore?.tags || implicitTags)],
})
const errorRSCPayload = await workUnitAsyncStorage.run(
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