mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
codex/fallback-root-cache
13 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3dbf921905 |
test: enable verified runtime deploy tests (#98457)
## Summary
Enable the same 9 previously selected deployment-test scopes across 9
runtime test files, now in a stack rooted on canary. Remove 8
`skipDeployment` options and their obsolete skip guards. Enable only the
selected middleware cookie assertion; the neighboring query assertion
remains excluded. Other mode, bundler, middleware, and Cache Components
exclusions remain in place.
This preserves the selection with passing evidence from the previous
deployment runs. No additional candidate scopes are enabled; excluded
variants are not counted as deployment coverage.
The worker-react-refresh scope (ID 411) remains deployment-excluded
pending fixture dependency changes: React 19.3.0 conflicts with
@react-three/fiber 9.7.0’s React <19.3 peer range. Both deploy variants
fail during npm installation, before the assertion executes. It is
tracked as a fixable candidate, not a permanent local-only test.
## Verification
- All selected test registration names and assertion bodies match the
previous enabled revision, checked by AST comparison.
- Verified that the canary diff contains only the inventoried exclusions
and their obsolete skip plumbing; other exclusions are preserved.
- Formatting and lint passed; 77 gate infrastructure unit tests passed.
- Full local bootstrap was blocked by missing package-level dependencies
in the temporary worktree. Fresh deployment execution on these rewritten
commits remains to be verified in CI.
<details>
<summary>Preserved scope inventory (9)</summary>
- ID 350: `test/e2e/app-dir/app-edge-root-layout/index.test.ts` —
`describe('app-dir edge runtime root layout', () => {
const { next, isNextStart } = nextTestSetup({
files: __dirname,
})
it('should not emit metadata files into bad paths', async () => {
await next.fetch('/favicon.ico')
// issue: If metadata files are not filter out properly with
image-loader,
// an incorrect static/media folder will be generated
// Check that the static folder is not generated
const incorrectGeneratedStaticFolder = await next.hasFile('static')
expect(incorrectGeneratedStaticFolder).toBe(false)
})
if (isNextStart) {
it('should mark static contain metadata routes as edge functions', async
() => {
const middlewareManifest = await next.readFile(
'.next/server/middleware-manifest.json'
)
expect(middlewareManifest).not.toContain('/favicon')
})
}
})`
- ID 353: `test/e2e/app-dir/binary/rsc-binary.test.ts` — `describe('RSC
binary serialization', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
'server-only': 'latest',
},
})
afterEach(async () => {
await next.stop()
})
it('should correctly encode/decode binaries and hydrate', async function
() {
const browser = await next.browser('/')
await check(async () => {
const content = await browser.elementByCss('body').text()
return content.includes('utf8 binary: hello') &&
content.includes('arbitrary binary: 255,0,1,2,3') &&
content.includes('hydrated: true')
? 'success'
: 'fail'
}, 'success')
})
})`
- ID 355:
`test/e2e/app-dir/interception-middleware-rewrite/interception-middleware-rewrite.test.ts`
— `describe('interception-middleware-rewrite', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should support intercepting routes with a middleware rewrite', async
() => {
const browser = await next.browser('/')
await check(() => browser.elementByCss('#children').text(), 'root')
await check(
() =>
browser
.elementByCss('[href="/feed"]')
.click()
.elementByCss('#modal')
.text(),
'intercepted'
)
await check(
() => browser.refresh().elementByCss('#children').text(),
'not intercepted'
)
await check(() => browser.elementByCss('#modal').text(), 'default')
})
it('should continue to work after using browser back button and
following another intercepting route', async () => {
const browser = await next.browser('/')
await check(() => browser.elementById('children').text(), 'root')
await browser.elementByCss('[href="/photos/1"]').click()
await check(
() => browser.elementById('modal').text(),
'Intercepted Photo ID: 1'
)
await browser.back()
await browser.elementByCss('[href="/photos/2"]').click()
await check(
() => browser.elementById('modal').text(),
'Intercepted Photo ID: 2'
)
})
it('should continue to show the intercepted page when revisiting it',
async () => {
const browser = await next.browser('/')
await check(() => browser.elementById('children').text(), 'root')
await browser.elementByCss('[href="/photos/1"]').click()
// we should be showing the modal and not the page
await check(
() => browser.elementById('modal').text(),
'Intercepted Photo ID: 1'
)
await browser.refresh()
// page should show after reloading the browser
await check(
() => browser.elementById('children').text(),
'Page Photo ID: 1'
)
// modal should no longer be showing
await check(() => browser.elementById('modal').text(), 'default')
await browser.back()
// revisit the same page that was intercepted
await browser.elementByCss('[href="/photos/1"]').click()
// ensure that we're still showing the modal and not the page
await check(
() => browser.elementById('modal').text(),
'Intercepted Photo ID: 1'
)
// page content should not have changed
await check(() => browser.elementById('children').text(), 'root')
})
})`
- ID 360: `test/e2e/app-dir/middleware-matching/index.test.ts` —
`describe('app dir - middleware with custom matcher', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should match /:id (without asterisk)', async () => {
const browser = await next.browser('/chat/123')
expect(await browser.elementByCss('p').text()).toBe('Home')
})
})`
- ID 361:
`test/e2e/app-dir/node-extensions/node-extensions.random.test.ts` —
`describe('Cache Components', () => {
const { next } = nextTestSetup({
files: __dirname + '/fixtures/random/cache-components',
})
it('should not error when accessing middlware that use Math.random()',
async () => {
let res: Awaited<ReturnType<typeof next.fetch>>,
$: Awaited<ReturnType<typeof next.render$>>
res = await next.fetch('/rewrite')
expect(res.status).toBe(200)
$ = await next.render$('/rewrite')
expect($('[data-testid="content"]').text()).toBe('rewritten')
})
it('should not error when accessing pages that use Math.random() in App
Router', async () => {
let res, $
res = await next.fetch('/app/prerendered/unstable-cache')
expect(res.status).toBe(200)
$ = await next.render$('/app/prerendered/unstable-cache')
expect($('li').length).toBe(2)
res = await next.fetch('/app/prerendered/use-cache')
expect(res.status).toBe(200)
$ = await next.render$('/app/prerendered/use-cache')
expect($('li').length).toBe(2)
res = await next.fetch('/app/rendered/uncached')
expect(res.status).toBe(200)
$ = await next.render$('/app/rendered/uncached')
expect($('li').length).toBe(2)
res = await next.fetch('/app/rendered/unstable-cache')
expect(res.status).toBe(200)
$ = await next.render$('/app/rendered/unstable-cache')
expect($('li').length).toBe(2)
res = await next.fetch('/app/rendered/use-cache')
expect(res.status).toBe(200)
$ = await next.render$('/app/rendered/use-cache')
expect($('li').length).toBe(2)
})
it('should not error when accessing routes that use Math.random() in App
Router', async () => {
let res, body
res = await next.fetch('/app/prerendered/uncached/api')
expect(res.status).toBe(200)
body = await res.json()
expect(body).toEqual({
rand1: expect.any(Number),
rand2: expect.any(Number),
})
res = await next.fetch('/app/prerendered/unstable-cache/api')
expect(res.status).toBe(200)
body = await res.json()
expect(body).toEqual({
rand1: expect.any(Number),
rand2: expect.any(Number),
})
res = await next.fetch('/app/prerendered/use-cache/api')
expect(res.status).toBe(200)
body = await res.json()
expect(body).toEqual({
rand1: expect.any(Number),
rand2: expect.any(Number),
})
res = await next.fetch('/app/rendered/uncached/api')
expect(res.status).toBe(200)
body = await res.json()
expect(body).toEqual({
rand1: expect.any(Number),
rand2: expect.any(Number),
})
res = await next.fetch('/app/rendered/unstable-cache/api')
expect(res.status).toBe(200)
body = await res.json()
expect(body).toEqual({
rand1: expect.any(Number),
rand2: expect.any(Number),
})
res = await next.fetch('/app/rendered/use-cache/api')
expect(res.status).toBe(200)
body = await res.json()
expect(body).toEqual({
rand1: expect.any(Number),
rand2: expect.any(Number),
})
})
it('should not error when accessing pages that use Math.random() in
Pages Router', async () => {
let res, $
res = await next.fetch('/pages/gip/random')
expect(res.status).toBe(200)
$ = await next.render$('/pages/gip/random')
expect($('li').length).toBe(2)
res = await next.fetch('/pages/gssp/random')
expect(res.status).toBe(200)
$ = await next.render$('/pages/gssp/random')
expect($('li').length).toBe(2)
res = await next.fetch('/pages/gsp/random')
expect(res.status).toBe(200)
$ = await next.render$('/pages/gsp/random')
expect($('li').length).toBe(2)
})
it('should not error when accessing routes that use Math.random() in
Pages Router', async () => {
let res, body
res = await next.fetch('/api/random')
expect(res.status).toBe(200)
body = await res.json()
expect(body).toEqual({
rand1: expect.any(Number),
rand2: expect.any(Number),
})
expect(body.rand1).not.toBe(body.rand2)
const first1 = body.rand1
const first2 = body.rand2
res = await next.fetch('/api/random')
body = await res.json()
expect(body.rand1).not.toBe(body.rand2)
expect(body.rand1).not.toBe(first1)
expect(body.rand2).not.toBe(first2)
})
})`
- ID 370:
`test/e2e/app-dir/webpack-loader-binary/webpack-loader-binary.test.ts` —
`describe('webpack-loader-ts-transform', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should allow passing binary assets to and from a Webpack loader',
async () => {
const $ = await next.render$('/')
expect($('#text').text()).toBe('Got a buffer of 18 bytes')
expect($('#binary').text()).toBe('Got a buffer of 6765 bytes')
})
})`
- ID 386:
`test/e2e/edge-runtime-uses-edge-light-import-specifier-for-packages/edge-runtime-uses-edge-light-import-specifier-for-packages.test.ts`
— `describe('edge-runtime uses edge-light import specifier for
packages', () => {
const { next } = nextTestSetup({
files: __dirname,
packageJson: {
scripts: {
build: 'next build',
dev: 'next dev',
start: 'next start',
},
},
installCommand: 'pnpm i',
startCommand: (global as any).isNextDev ? 'pnpm dev' : 'pnpm start',
buildCommand: 'pnpm build',
})
// In case you need to test the response object
it('pages/api endpoints import the correct module', async () => {
const res = await next.fetch('/api/edge')
const html = await res.json()
expect(html).toEqual({
// edge-light is only supported in `exports` and `imports` but webpack
also adds the top level `edge-light` key incorrectly.
edgeLightPackage: process.env.IS_TURBOPACK_TEST ? 'import' :
'edge-light',
edgeLightPackageExports: 'edge-light',
})
})
it('pages import the correct module', async () => {
const $ = await next.render$('/')
const text = JSON.parse($('pre#result').text())
expect(text).toEqual({
// edge-light is only supported in `exports` and `imports` but webpack
also adds the top level `edge-light` key incorrectly.
edgeLightPackage: process.env.IS_TURBOPACK_TEST ? 'import' :
'edge-light',
edgeLightPackageExports: 'edge-light',
})
})
it('app-dir imports the correct module', async () => {
const $ = await next.render$('/app-dir')
const text = JSON.parse($('pre#result').text())
expect(text).toEqual({
// edge-light is only supported in `exports` and `imports` but webpack
also adds the top level `edge-light` key incorrectly.
edgeLightPackage: process.env.IS_TURBOPACK_TEST ? 'import' :
'edge-light',
edgeLightPackageExports: 'edge-light',
})
})
})`
- ID 392: `test/e2e/middleware-custom-matchers/test/index.test.ts` —
`it('should match has cookie on client routing', async () => {
const browser = await next.browser('/routes')
await browser.addCookie({ name: 'loggedIn', value: 'true' })
await browser.refresh()
await browser.eval('window.__TEST_NO_RELOAD = true')
await browser.elementById('has-match-3').click()
const fromMiddleware = await
browser.elementById('from-middleware').text()
expect(fromMiddleware).toBe('true')
const noReload = await browser.eval('window.__TEST_NO_RELOAD')
expect(noReload).toBe(true)
})`
- ID 402:
`test/e2e/on-request-error/skip-next-internal-error/skip-next-internal-error.test.ts`
— `describe('on-request-error - skip-next-internal-error', () => {
const { next } = nextTestSetup({
files: __dirname,
})
async function assertNoNextjsInternalErrors() {
const output = next.cliOutput
// No navigation errors
expect(output).not.toContain('NEXT_REDIRECT')
expect(output).not.toContain('NEXT_NOT_FOUND')
expect(output).not.toContain('BAILOUT_TO_CLIENT_SIDE_RENDERING')
// No dynamic usage errors
expect(output).not.toContain('DYNAMIC_SERVER_USAGE')
// No react postpone errors
// TODO: cover PPR errors later
expect(output).not.toContain('react.postpone')
}
describe('app router render', () => {
// Server navigation errors
it('should not catch server component not-found errors', async () => {
await next.fetch('/server/not-found')
await assertNoNextjsInternalErrors()
})
it('should not catch server component redirect errors', async () => {
await next.render('/server/redirect')
await assertNoNextjsInternalErrors()
})
// Client navigation errors
it('should not catch client component not-found errors', async () => {
await next.fetch('/server/not-found')
await assertNoNextjsInternalErrors()
})
it('should not catch client component redirect errors', async () => {
await next.render('/client/redirect')
await assertNoNextjsInternalErrors()
})
// Dynamic usage
it('should not catch server component dynamic usage errors', async () =>
{
await next.fetch('/server/dynamic-fetch')
await assertNoNextjsInternalErrors()
})
it('should not catch client component dynamic usage errors', async () =>
{
await next.fetch('/client/dynamic-fetch')
await assertNoNextjsInternalErrors()
})
// No SSR
it('should not catch next dynamic no-ssr errors', async () => {
await next.fetch('/client/no-ssr')
await assertNoNextjsInternalErrors()
})
// Server Actions navigation
it('should not catch server action not-found errors', async () => {
await next.fetch('/form/not-found')
await assertNoNextjsInternalErrors()
})
it('should not catch server action redirect errors', async () => {
await next.fetch('/form/redirect')
await assertNoNextjsInternalErrors()
})
})
describe('app router API', () => {
// API routes navigation errors
it('should not catch server component not-found errors', async () => {
await next.render('/app-route/not-found')
await assertNoNextjsInternalErrors()
})
it('should not catch server component redirect errors', async () => {
await next.render('/app-route/redirect')
await assertNoNextjsInternalErrors()
})
})
})`
</details>
<details>
<summary>Deployment evidence for the additional scopes</summary>
- `test/e2e/middleware-custom-matchers/test/index.test.ts` — `it('should
match has cookie on client routing', async () => {`:
[normal](https://github.com/vercel/next.js/actions/runs/34426785013/job/102715655249),
[cache](https://github.com/vercel/next.js/actions/runs/34426785013/job/102715655202).
</details>
<!-- NEXT_JS_LLM -->
|
||
|
|
85c3d20a91 |
[cache components]: move flag out of experimental (#85035)
This moves `experimental.cacheComponents` to a top level config. As part of this, I disabled some tests in `build-output-prerender` that assert on `cacheComponents` appearing in the experimental list. In a separate PR, I'm going to show that Cache Components is enabled next to the bundler info. This also updates some docs pages to remove "experimental" language. |
||
|
|
ed5d085fb1 |
[Cache Components] Error for Sync IO in Server Components during Static Prerender (#82500)
Currently we error if you cannot produce a shell unless you have a Suspense boundary above the root. This is fine for normal IO but sync IO like Math.random() and new Date() have much more significant bad consequences for prerendering. Instead of treating these errors as another flavor of "must have a shell" validation we should instead treat them like they must be guarded behind something else dynamic like `await connection()`. In addition to unconditionally erroring for Sync IO in Server Components when prerendering this change also removes the Sync IO warning for runtime prefetches. This is because at the moment there is no way to debug these errors in dev. In the future we will add validation for prefetches and need to add back in some ability to warn for these cases but until then we will leave this case as a silent deopt. |
||
|
|
8abbb3dc2e |
refactor: rename experimental.dynamicIO to experimental.cacheComponents (#81562)
## What? Rename `experimental.dynamicIO` to `experimental.cacheComponents` across the Next.js codebase. ## Why? We're going to be merging the functionality of the `ppr`, `dynamicIO` and `useCache` experimental flags into the singular `cacheComponents` flag to reduce complexity of the codebase and simplify adoption for users wanting to experiment with experimental features. ## How? - Renamed the configuration option from `experimental.dynamicIO` to `experimental.cacheComponents` - Added deprecation handling with automatic migration for the old option name - Updated all documentation, tests, and internal references - Updated Rust code in SWC transforms and Turbopack - Maintained backward compatibility with deprecation warnings NAR-158 |
||
|
|
d8fdb6ffa8 |
Simplify running test apps locally with ppr or dynamicIO enabled (#81668)
We want to respect the `__NEXT_EXPERIMENTAL_PPR` and `__NEXT_EXPERIMENTAL_CACHE_COMPONENTS` environment variables in the test apps, so that we can run them locally with these features enabled without needing to modify the config files. So we're removing the requirement that `__NEXT_TEST_MODE` needs to be set at the same time. Usually you don't want to set this variable locally because it also changes other behavior in a few places. This really has no downside, because it was already possible for users to set both variables and affect the flags, and now this can be done with a single variable. It allows us to keep the noise out of the test app's next config files. We're also moving the assignments from the default config into `enforceExperimentalFeatures` to get the nice output when printing the experimental features in the CLI. |
||
|
|
90a4e3af1d | [test] Move test selectors as close to the actual value as possible (Part 2) (#80416) | ||
|
|
2a95766744 |
Remove obsolete ppr configs from Dynamic IO tests (#79305)
Now that `ppr` is enabled by default when `dynamicIO` is enabled, we can remove the obsolete `ppr: true` configs from the Dynamic IO tests. |
||
|
|
53933954e3 |
Enable PPR in Dynamic IO tests (#79301)
To prepare for an upcoming change where `ppr` will be enabled automatically when `dynamicIO` is enabled, we're hard coding `ppr: true` in the Dynamic IO tests with this PR. The non-PPR assertions are subsequently removed, which makes up most of the changed lines. We can now also exclude the tests in the PPR tests manifest, so that they're not run twice in CI. > [!NOTE] > This PR is best reviewed with hidden whitespace changes. |
||
|
|
b15d481871 |
[dynamicIO] show dev & build warnings when using incompatible segment configs (#71500)
This logs an error in dev and fails a build when using incompatible segment configs (`dynamic`, `fetchCache`, `runtime`, `dynamicParams`) with dynamicIO. It will point to all discovered pages that contained the invalid segment config at the end of the build.  In dev, it will show the error in an overlay. The invalid segment configs must be removed to build.  Note: This removes all incompatible test cases that were previously part of the `dynamic-io` test suites, and disables one that was using a fetchCache workaround until it's properly handled. |
||
|
|
ddd9de497b |
[ppr] Stabilize Partial Prerendering Fallbacks (#71320)
This stabilizes Partial Prerendering Fallbacks (PFPR) so that when Partial Prerendering (PPR) is enabled, so is PFPR. |
||
|
|
1b871290df |
Add support for "use cache" in route handlers (#70897)
When compiling a route handler entry, we are now also generating client reference and server reference manifests. This enables `"use cache"` usage in route handlers. As a follow-up we should try to get rid of the `SERVER_ACTION_MANIFESTS_SINGLETON` and move the manifests to the `WorkStore`. |
||
|
|
9497f17657 |
Skip Math.random test with route handler and 'use cache' (#71025)
Using `'use cache'` in route handlers is not yet fully supported, and fails in isolation, e.g. in a deployment test, because it implicitly relies on the fact that a page must have been compiled before the route. Otherwise rendering the route errors with "Missing manifest for Server Actions.". This deploy test failure slipped through because #70837 was created from a fork. |
||
|
|
9e0ce4f618 |
[dynamicIO] Instrument Math.random() to be considered synchronously dynamic (#70837)
`Math.random()` is IO though it is synchronous. When `dynamicIO` is enabled we need to treat calls to `Math.random()` as IO and exclude them from prerenders unless they are cached. This change sets up the instrumentation for this behavior. Unless the sync access of async request APIs this patch does not yet have any dev warnings. These will be added in a future update when we can instrument the environment name during dev to tell the difference between the prerender phase, and render phase even without a build |