Skip to content

Commit bd164d5

Browse files
committedSep 11, 2024·
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)
1 parent ff04bc2 commit bd164d5

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed
 

‎packages/next/src/server/base-server.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -2385,10 +2385,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
23852385

23862386
return {
23872387
...result,
2388-
revalidate:
2389-
result.revalidate !== undefined
2390-
? result.revalidate
2391-
: /* default to minimum revalidate (this should be an invariant) */ 1,
2388+
revalidate: result.revalidate,
23922389
}
23932390
},
23942391
{

‎packages/next/src/server/render.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,7 @@ export async function renderToHTMLImpl(
10671067
})
10681068
)
10691069
canAccessRes = false
1070+
renderResultMeta.revalidate = 0
10701071
} catch (serverSidePropsError: any) {
10711072
// remove not found error code to prevent triggering legacy
10721073
// 404 rendering

‎test/production/standalone-mode/required-server-files/required-server-files-i18n.test.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,16 @@ describe('required server files i18n', () => {
344344
expect(isNaN(data2.random)).toBe(false)
345345
expect(data2.random).not.toBe(data.random)
346346

347-
const html3 = await renderViaHTTP(appPort, '/some-other-path', undefined, {
348-
headers: {
349-
'x-matched-path': '/dynamic/[slug]?slug=%5Bslug%5D.json',
350-
'x-now-route-matches': '1=second&nxtPslug=second',
351-
},
352-
})
347+
const html3 = await renderViaHTTP(
348+
appPort,
349+
'/some-other-path?nxtPslug=second',
350+
undefined,
351+
{
352+
headers: {
353+
'x-matched-path': '/dynamic/[slug]?slug=%5Bslug%5D.json',
354+
},
355+
}
356+
)
353357
const $3 = cheerio.load(html3)
354358
const data3 = JSON.parse($3('#props').text())
355359

‎test/production/standalone-mode/required-server-files/required-server-files.test.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,16 @@ describe('required server files', () => {
617617
expect(isNaN(data2.random)).toBe(false)
618618
expect(data2.random).not.toBe(data.random)
619619

620-
const html3 = await renderViaHTTP(appPort, '/some-other-path', undefined, {
621-
headers: {
622-
'x-matched-path': '/dynamic/[slug]',
623-
'x-now-route-matches': '1=second&nxtPslug=second',
624-
},
625-
})
620+
const html3 = await renderViaHTTP(
621+
appPort,
622+
'/some-other-path?nxtPslug=second',
623+
undefined,
624+
{
625+
headers: {
626+
'x-matched-path': '/dynamic/[slug]',
627+
},
628+
}
629+
)
626630
const $3 = cheerio.load(html3)
627631
const data3 = JSON.parse($3('#props').text())
628632

0 commit comments

Comments
 (0)
Please sign in to comment.