Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { notFound } from 'next/navigation'

export const dynamicParams = true

export default function SlugPage() {
notFound()
}
8 changes: 8 additions & 0 deletions test/production/app-dir/isr-index-cache-key/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
5 changes: 5 additions & 0 deletions test/production/app-dir/isr-index-cache-key/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const revalidate = 1

export default function Page() {
return <p data-generation={Date.now()}>home</p>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'

describe('app dir ISR index cache key', () => {
const { next } = nextTestSetup({
files: __dirname,
})

function getGeneration(html: string) {
const match = html.match(/data-generation="(\d+)"/)
if (!match) throw new Error('Missing home generation')
return Number(match[1])
}

it('does not let a not-found /index request poison the home cache', async () => {
const initialHome = await next.fetch('/')
expect(initialHome.status).toBe(200)
const initialGeneration = getGeneration(await initialHome.text())

let currentGeneration = initialGeneration
await retry(async () => {
const home = await next.fetch('/')
expect(home.status).toBe(200)
currentGeneration = getGeneration(await home.text())
expect(currentGeneration).toBeGreaterThan(initialGeneration)
}, 5000)

await retry(
() => {
expect(Date.now()).toBeGreaterThanOrEqual(currentGeneration + 1000)
},
3000,
100
)

await (await next.fetch('/index')).text()
await retry(async () => {
const index = await next.fetch('/index')
expect(index.status).toBe(404)
await index.text()
}, 5000)

const finalHome = await next.fetch('/')
expect(finalHome.status).toBe(200)
expect(getGeneration(await finalHome.text())).toBeGreaterThan(0)
})
})
6 changes: 6 additions & 0 deletions test/production/app-dir/isr-index-cache-key/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}

module.exports = nextConfig