first commit
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled

This commit is contained in:
Arian Tron
2026-03-10 19:37:31 +03:30
commit 61f56f997c
27684 changed files with 2784175 additions and 0 deletions

View File

@@ -0,0 +1,190 @@
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
import * as nodePath from 'node:path'
import type { Playwright } from '../../../lib/next-webdriver'
describe.each([
{
description: 'without runtime prefetch configs',
hasRuntimePrefetch: false,
fixturePath: 'fixtures/without-prefetch-config',
},
{
description: 'with runtime prefetch configs',
hasRuntimePrefetch: true,
fixturePath: 'fixtures/with-prefetch-config',
},
])(
'cache-components-tasks - $description',
({ fixturePath, hasRuntimePrefetch }) => {
const { next, isTurbopack, isNextDev } = nextTestSetup({
files: nodePath.join(__dirname, fixturePath),
})
function assertLog(
logs: Array<{ source: string; message: string }>,
message: string,
expectedEnvironment: string
) {
// Match logs that contain the message, with any environment.
const logPattern = new RegExp(
`^(?=.*\\b${message}\\b)(?=.*\\b(Cache|Prerender|Prefetch|Prefetchable|Server)\\b).*`
)
const logMessages = logs.map((log) => log.message)
const messages = logMessages.filter((message) => logPattern.test(message))
// If there's zero or more than one logs that match, the test is not set up correctly.
if (messages.length === 0) {
throw new Error(
`Found no logs matching '${message}':\n\n${logMessages.map((s, i) => `${i}. ${s}`).join('\n')}}`
)
}
if (messages.length > 1) {
throw new Error(
`Found multiple logs matching '${message}':\n\n${messages.map((s, i) => `${i}. ${s}`).join('\n')}`
)
}
// The message should have the expected environment.
const actualMessageText = messages[0]
const [, actualEnvironment] = actualMessageText.match(logPattern)!
expect([actualEnvironment, actualMessageText]).toEqual([
expectedEnvironment,
expect.stringContaining(message),
])
}
function assertNoUnexpectedErrorsInCli() {
// We should not see any errors related to the aborted render.
expect(next.cliOutput).not.toContain(
'AbortError: This operation was aborted'
)
// We should not see warnings related to setTimeout.
expect(next.cliOutput).not.toContain(
"Next.js cannot guarantee that Cache Components will run as expected due to the current runtime's implementation of `setTimeout()`"
)
}
async function testInitialLoad(
path: string,
assertLogs: (browser: Playwright) => Promise<void>
) {
const browser = await next.browser(path)
// Initial load.
await retry(() => assertLogs(browser))
assertNoUnexpectedErrorsInCli()
// After another load (with warm caches) the logs should be the same.
await browser.loadPage(next.url + path) // clears old logs
await retry(() => assertLogs(browser))
assertNoUnexpectedErrorsInCli()
if (isNextDev && isTurbopack) {
// FIXME:
// In Turbopack, requests to the /revalidate route seem to occasionally crash
// due to some HMR or compilation issue. `revalidatePath` throws this error:
//
// Invariant: static generation store missing in revalidatePath <path>
//
// This is unrelated to the logic being tested here, so for now, we skip the assertions
// that require us to revalidate.
console.log('WARNING: skipping revalidation assertions in turbopack')
return
}
// After a revalidation the subsequent warmup render must discard stale
// cache entries.
// This should not affect the environment labels.
await revalidatePath(path)
await browser.loadPage(next.url + path) // clears old logs
await retry(() => assertLogs(browser))
assertNoUnexpectedErrorsInCli()
}
async function testNavigation(
path: string,
assertLogs: (browser: Playwright) => Promise<void>
) {
const browser = await next.browser('/')
// Initial nav (first time loading the page)
await browser.elementByCss(`a[href="${path}"]`).click()
await retry(() => assertLogs(browser))
assertNoUnexpectedErrorsInCli()
// Reload, and perform another nav (with warm caches). the logs should be the same.
await browser.loadPage(next.url + '/') // clears old logs
await browser.elementByCss(`a[href="${path}"]`).click()
await retry(() => assertLogs(browser))
assertNoUnexpectedErrorsInCli()
if (isNextDev && isTurbopack) {
// FIXME:
// In Turbopack, requests to the /revalidate route seem to occasionally crash
// due to some HMR or compilation issue. `revalidatePath` throws this error:
//
// Invariant: static generation store missing in revalidatePath <path>
//
// This is unrelated to the logic being tested here, so for now, we skip the assertions
// that require us to revalidate.
console.log('WARNING: skipping revalidation assertions in turbopack')
return
}
// After a revalidation the subsequent warmup render must discard stale
// cache entries.
// This should not affect the environment labels.
await revalidatePath(path)
await browser.loadPage(next.url + '/') // clears old logs
await browser.elementByCss(`a[href="${path}"]`).click()
await retry(() => assertLogs(browser))
assertNoUnexpectedErrorsInCli()
}
async function revalidatePath(path: string) {
const response = await next.fetch(
`/revalidate?path=${encodeURIComponent(path)}`
)
if (!response.ok) {
throw new Error(
`Failed to revalidate path: '${path}' - server responded with status ${response.status}`
)
}
}
const RUNTIME_ENV = hasRuntimePrefetch ? 'Prefetch' : 'Prefetchable'
describe.each([
{ description: 'initial load', isInitialLoad: true },
{ description: 'navigation', isInitialLoad: false },
])('$description', ({ isInitialLoad }) => {
it('setImmediate resolves between tasks', async () => {
const path = '/simple'
const assertLogs = async (browser: Playwright) => {
const logs = await browser.log()
assertLog(logs, 'after immediate - static - layout', 'Prerender')
assertLog(logs, 'after immediate - static - page', 'Prerender')
assertLog(logs, 'after cookies - layout', RUNTIME_ENV)
assertLog(logs, 'after cookies - page', RUNTIME_ENV)
assertLog(logs, 'after immediate - runtime - layout', RUNTIME_ENV)
assertLog(logs, 'after immediate - runtime - page', RUNTIME_ENV)
assertLog(logs, 'after connection - layout', 'Server')
assertLog(logs, 'after connection - page', 'Server')
assertLog(logs, 'after immediate - dynamic - layout', 'Server')
assertLog(logs, 'after immediate - dynamic - page', 'Server')
}
if (isInitialLoad) {
await testInitialLoad(path, assertLogs)
} else {
await testNavigation(path, assertLogs)
}
})
})
}
)

View File

@@ -0,0 +1,7 @@
export default function Root({ children }: { children: React.ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}

View File

@@ -0,0 +1,14 @@
import Link from 'next/link'
export default function Page() {
// NOTE: these links must be kept in sync with `path` variables used in the test
return (
<main>
<ul>
<li>
<Link href="/simple">/simple</Link>
</li>
</ul>
</main>
)
}

View File

@@ -0,0 +1,8 @@
import { revalidatePath } from 'next/cache'
export async function GET(request: Request) {
const path = new URL(request.url).searchParams.get('path')!
revalidatePath(path)
return Response.json({ revalidated: true })
}

View File

@@ -0,0 +1,31 @@
import { cookies } from 'next/headers'
import { connection } from 'next/server'
function immediate() {
return new Promise<void>((resolve) => setImmediate(resolve))
}
export async function Static({ label }: { label: string }) {
await immediate()
await immediate()
console.log(`after immediate - static - ${label}`)
return <div>Static - {label}</div>
}
export async function Runtime({ label }: { label: string }) {
await cookies()
console.log(`after cookies - ${label}`)
await immediate()
await immediate()
console.log(`after immediate - runtime - ${label}`)
return <div>Runtime - {label}</div>
}
export async function Dynamic({ label }: { label: string }) {
await connection()
console.log(`after connection - ${label}`)
await immediate()
await immediate()
console.log(`after immediate - dynamic - ${label}`)
return <div>Dynamic - {label}</div>
}

View File

@@ -0,0 +1,22 @@
import { Suspense } from 'react'
import { Static, Runtime, Dynamic } from '../shared'
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
export default function Root({ children }: { children: React.ReactNode }) {
return (
<>
<div>
<Static label="layout" />
<Suspense fallback="Loading...">
<Runtime label="layout" />
</Suspense>
<Suspense fallback="Loading...">
<Dynamic label="layout" />
</Suspense>
</div>
<hr />
{children}
</>
)
}

View File

@@ -0,0 +1,16 @@
import { Suspense } from 'react'
import { Static, Runtime, Dynamic } from '../shared'
export default async function Page() {
return (
<main>
<Static label="page" />
<Suspense fallback="Loading...">
<Runtime label="page" />
</Suspense>
<Suspense fallback="Loading...">
<Dynamic label="page" />
</Suspense>
</main>
)
}

View File

@@ -0,0 +1,7 @@
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
cacheComponents: true,
}
export default nextConfig

View File

@@ -0,0 +1,7 @@
export default function Root({ children }: { children: React.ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}

View File

@@ -0,0 +1,14 @@
import Link from 'next/link'
export default function Page() {
// NOTE: these links must be kept in sync with `path` variables used in the test
return (
<main>
<ul>
<li>
<Link href="/simple">/simple</Link>
</li>
</ul>
</main>
)
}

View File

@@ -0,0 +1,8 @@
import { revalidatePath } from 'next/cache'
export async function GET(request: Request) {
const path = new URL(request.url).searchParams.get('path')!
revalidatePath(path)
return Response.json({ revalidated: true })
}

View File

@@ -0,0 +1,31 @@
import { cookies } from 'next/headers'
import { connection } from 'next/server'
function immediate() {
return new Promise<void>((resolve) => setImmediate(resolve))
}
export async function Static({ label }: { label: string }) {
await immediate()
await immediate()
console.log(`after immediate - static - ${label}`)
return <div>Static - {label}</div>
}
export async function Runtime({ label }: { label: string }) {
await cookies()
console.log(`after cookies - ${label}`)
await immediate()
await immediate()
console.log(`after immediate - runtime - ${label}`)
return <div>Runtime - {label}</div>
}
export async function Dynamic({ label }: { label: string }) {
await connection()
console.log(`after connection - ${label}`)
await immediate()
await immediate()
console.log(`after immediate - dynamic - ${label}`)
return <div>Dynamic - {label}</div>
}

View File

@@ -0,0 +1,20 @@
import { Suspense } from 'react'
import { Static, Runtime, Dynamic } from '../shared'
export default function Root({ children }: { children: React.ReactNode }) {
return (
<>
<div>
<Static label="layout" />
<Suspense fallback="Loading...">
<Runtime label="layout" />
</Suspense>
<Suspense fallback="Loading...">
<Dynamic label="layout" />
</Suspense>
</div>
<hr />
{children}
</>
)
}

View File

@@ -0,0 +1,16 @@
import { Suspense } from 'react'
import { Static, Runtime, Dynamic } from '../shared'
export default async function Page() {
return (
<main>
<Static label="page" />
<Suspense fallback="Loading...">
<Runtime label="page" />
</Suspense>
<Suspense fallback="Loading...">
<Dynamic label="page" />
</Suspense>
</main>
)
}

View File

@@ -0,0 +1,7 @@
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
cacheComponents: true,
}
export default nextConfig