Skip to content

Commit 7ed7f12

Browse files
committed
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 99de057 commit 7ed7f12

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
@@ -2573,10 +2573,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
25732573

25742574
return {
25752575
...result,
2576-
revalidate:
2577-
result.revalidate !== undefined
2578-
? result.revalidate
2579-
: /* default to minimum revalidate (this should be an invariant) */ 1,
2576+
revalidate: result.revalidate,
25802577
}
25812578
},
25822579
{

packages/next/src/server/render.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,7 @@ export async function renderToHTMLImpl(
10891089
})
10901090
)
10911091
canAccessRes = false
1092+
metadata.revalidate = 0
10921093
} catch (serverSidePropsError: any) {
10931094
// remove not found error code to prevent triggering legacy
10941095
// 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
@@ -345,12 +345,16 @@ describe('required server files i18n', () => {
345345
expect(isNaN(data2.random)).toBe(false)
346346
expect(data2.random).not.toBe(data.random)
347347

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

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

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

625-
const html3 = await renderViaHTTP(appPort, '/some-other-path', undefined, {
626-
headers: {
627-
'x-matched-path': '/dynamic/[slug]',
628-
'x-now-route-matches': '1=second&nxtPslug=second',
629-
},
630-
})
625+
const html3 = await renderViaHTTP(
626+
appPort,
627+
'/some-other-path?nxtPslug=second',
628+
undefined,
629+
{
630+
headers: {
631+
'x-matched-path': '/dynamic/[slug]',
632+
},
633+
}
634+
)
631635
const $3 = cheerio.load(html3)
632636
const data3 = JSON.parse($3('#props').text())
633637

0 commit comments

Comments
 (0)