Commit bd164d53 authored by JJ Kasper's avatar JJ Kasper

Remove invalid fallback revalidate value (#69990)

This removes our invalid revalidate default fallback when a revalidate
value isn't returned from render as render should always return a valid
value. We also already have an invariant when an invalid revalidate
value is returned we just need to ensure that case could be hit
properly. This also fixes some invalid test cases which were sending
invalid headers.

x-ref: [slack
thread](https://vercel.slack.com/archives/C0676QZBWKS/p1726061828198529?thread_ts=1720714625.621179&cid=C0676QZBWKS)
parent ff04bc2a
......@@ -2385,10 +2385,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
return {
...result,
revalidate:
result.revalidate !== undefined
? result.revalidate
: /* default to minimum revalidate (this should be an invariant) */ 1,
revalidate: result.revalidate,
}
},
{
......
......@@ -1067,6 +1067,7 @@ export async function renderToHTMLImpl(
})
)
canAccessRes = false
renderResultMeta.revalidate = 0
} catch (serverSidePropsError: any) {
// remove not found error code to prevent triggering legacy
// 404 rendering
......
......@@ -344,12 +344,16 @@ describe('required server files i18n', () => {
expect(isNaN(data2.random)).toBe(false)
expect(data2.random).not.toBe(data.random)
const html3 = await renderViaHTTP(appPort, '/some-other-path', undefined, {
headers: {
'x-matched-path': '/dynamic/[slug]?slug=%5Bslug%5D.json',
'x-now-route-matches': '1=second&nxtPslug=second',
},
})
const html3 = await renderViaHTTP(
appPort,
'/some-other-path?nxtPslug=second',
undefined,
{
headers: {
'x-matched-path': '/dynamic/[slug]?slug=%5Bslug%5D.json',
},
}
)
const $3 = cheerio.load(html3)
const data3 = JSON.parse($3('#props').text())
......
......@@ -617,12 +617,16 @@ describe('required server files', () => {
expect(isNaN(data2.random)).toBe(false)
expect(data2.random).not.toBe(data.random)
const html3 = await renderViaHTTP(appPort, '/some-other-path', undefined, {
headers: {
'x-matched-path': '/dynamic/[slug]',
'x-now-route-matches': '1=second&nxtPslug=second',
},
})
const html3 = await renderViaHTTP(
appPort,
'/some-other-path?nxtPslug=second',
undefined,
{
headers: {
'x-matched-path': '/dynamic/[slug]',
},
}
)
const $3 = cheerio.load(html3)
const data3 = JSON.parse($3('#props').text())
......
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