Unverified Commit 6be1a0e9 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Format all READMEs with Prettier (#100310)

## What?

Anchors the `readme.md` rule in `.prettierignore` to the root symlink
(`/readme.md`) and formats every README with Prettier, so that README
files are covered by `pnpm prettier-check` and lint-staged.

## Why?

The `readme.md` entry was meant for the root `readme.md` symlink. It
isn't anchored, and Prettier matches ignore patterns case-insensitively,
so it excluded every `README.md` in the repo (over 300 files). Those
files were never format-checked, and about two dozen had drifted.

## How?

- Anchors the entry as `/readme.md`, so it lists only the root symlink
alongside the other `# Symlink files` entries and no longer matches
nested READMEs. The entry documents the symlink rather than changing
behavior: Prettier already skips symlinks when it expands a directory
such as `prettier --check .`. The symlink's target,
`packages/next/README.md`, is now formatted directly.
- Runs Prettier 3.6.2 over all tracked README files. The changes are
formatting only:
  - padding table separator rows
  - adding blank lines before lists and code blocks
  - changing `*emphasis*` to `_emphasis_` and `*` bullets to `-`
  - normalizing list indentation
  - removing one optional semicolon from a fenced JS example
- No wording, links or code samples change in meaning.

## Verification

- `npx --yes prettier@3.6.2 --check .` passes, as it did before the
change.
- Every tracked README passes `prettier --check`, and `--file-info`
reports READMEs as no longer ignored.
- `git diff --ignore-all-space --ignore-blank-lines` shows only Markdown
normalization.

<!-- NEXT_JS_LLM -->


<!-- fleet 9072af3c-95f7-4175-a93d-5b232fe92150 -->

---------
Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 9b289dc0
......@@ -5,11 +5,13 @@ Skills are on-demand context files that Claude loads when relevant. They extend
## When to Create a Skill
Create a skill when content is:
- **Too detailed for AGENTS.md** (code templates, multi-step workflows, diagnostic procedures)
- **Only relevant for specific tasks** (not every session needs it)
- **Self-contained enough to load independently**
Do NOT create a skill for:
- One-liner rules or guardrails (keep those in AGENTS.md)
- Content every agent session needs (that's what AGENTS.md is for)
- Simple facts without actionable steps
......@@ -39,18 +41,18 @@ description: >
### Supported Frontmatter Fields
| Field | Required | Description |
|-------|----------|-------------|
| `name` | Yes | Skill name, used for `$name` references and `/name` slash commands |
| `description` | Yes | What the skill does and when to use it. **This is how Claude decides to auto-load the skill.** Include file names, concepts, and keywords. |
| `argument-hint` | No | Hint for expected arguments in autocomplete |
| `user-invocable` | No | Set to `false` to hide from `/` slash command menu |
| `disable-model-invocation` | No | Set to `true` to prevent Claude from auto-triggering this skill |
| `allowed-tools` | No | Tools Claude can use without permission when this skill is active |
| `model` | No | Model override for this skill |
| `context` | No | Set to `fork` for isolated subagent execution |
| `agent` | No | Subagent type to use with `context: fork` |
| `hooks` | No | Hooks scoped to this skill's lifecycle |
| Field | Required | Description |
| -------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `name` | Yes | Skill name, used for `$name` references and `/name` slash commands |
| `description` | Yes | What the skill does and when to use it. **This is how Claude decides to auto-load the skill.** Include file names, concepts, and keywords. |
| `argument-hint` | No | Hint for expected arguments in autocomplete |
| `user-invocable` | No | Set to `false` to hide from `/` slash command menu |
| `disable-model-invocation` | No | Set to `true` to prevent Claude from auto-triggering this skill |
| `allowed-tools` | No | Tools Claude can use without permission when this skill is active |
| `model` | No | Model override for this skill |
| `context` | No | Set to `fork` for isolated subagent execution |
| `agent` | No | Subagent type to use with `context: fork` |
| `hooks` | No | Hooks scoped to this skill's lifecycle |
Only use fields from this table. Unknown fields are ignored by Claude Code.
......
......@@ -44,6 +44,7 @@ The root `conductor.json` defines:
### Creating a New Workspace
In the Conductor app:
1. Add this repository
2. Create a new workspace with a descriptive name
3. The setup script will automatically install dependencies and build
......@@ -70,6 +71,7 @@ cd ../next.js-worktrees/my-feature
## Managing Worktrees
View all worktrees:
```bash
git worktree list
```
......@@ -77,16 +79,19 @@ git worktree list
## Best Practices
### Disk Space Management
- Each worktree uses ~500MB-1GB after build
- Run `pnpm sweep` periodically to clean Rust build artifacts
- Remove unused worktrees with `git worktree remove <path>`
### Development Workflow
1. **Never run `pnpm build` while `pnpm dev` is active** (causes build corruption)
2. Use `pnpm test-dev-turbo` for fastest test iteration
3. Use `NEXT_SKIP_ISOLATE=1` for faster test runs during development
### Parallel Agent Recommendations
- Limit to 3-4 concurrent agents to avoid:
- GitHub API rate limits
- Disk space exhaustion
......@@ -95,7 +100,9 @@ git worktree list
## Troubleshooting
### Build Corruption
If builds become corrupted:
```bash
# Kill any running dev processes
pkill -f "pnpm dev"
......@@ -107,6 +114,7 @@ pnpm build
```
### Worktree Issues
```bash
# List worktrees with status
git worktree list
......
......@@ -40,10 +40,10 @@ inherited, and `persist-credentials` is false.
For one steadily waiting middle PR (assuming each PR list fits one page):
| Poll | REST reads | What is checked |
| --- | ---: | --- |
| First and every 20 minutes | **8** | Current PR, successor, three predecessor links, three required checks |
| At 5, 10 and 15 minutes between refreshes | **3** each | Three required checks only; same-SHA reruns are still detected |
| Poll | REST reads | What is checked |
| ----------------------------------------- | ---------: | --------------------------------------------------------------------- |
| First and every 20 minutes | **8** | Current PR, successor, three predecessor links, three required checks |
| At 5, 10 and 15 minutes between refreshes | **3** each | Three required checks only; same-SHA reruns are still detected |
That is **8 + 3 + 3 + 3 = 17 reads per 20 minutes, or 51/hour**. Without this
optimization, five-minute topology discovery would use **8 × 12 = 96/hour**,
......@@ -52,7 +52,7 @@ responses supply head/base metadata, so cached predecessors need no extra PR
GETs on status-only ticks. Always check all three statuses: an older PR may
pass while a nearer one is pending or failed.
A retarget, closure, or newly added leaf can take up to 20 minutes to be
classified while waiting; no stale cache may *decide* the gate. Before opening
classified while waiting; no stale cache may _decide_ the gate. Before opening
or failing, re-read the current PR, decisive predecessor(s) and checks (up to
**3 extra reads for success, 7 for all-failed**). If validation detects changed
PR revisions, refresh topology **immediately**; repeated invalidations back
......
......@@ -83,7 +83,7 @@ test/development/mcp-server/fixtures/compilation-errors-app/app/syntax-error/pag
/apps/*/next-env.d.ts
# Symlink files
readme.md
/readme.md
test/development/app-dir/hmr-symlink/app/symlink-chain/page.tsx
test/development/app-dir/hmr-symlink/app/symlink-link/page.tsx
test/development/app-dir/ssr-in-rsc/node_modules/random-react-library
......
......@@ -4,7 +4,6 @@ A Next.js application for visualizing bundle sizes and analyzing dependencies us
This package is not published to npm. Instead it's built and vendored into the main `next` package during its build process.
## Features
- 📊 **Interactive Treemap**: Visualize bundle sizes with an interactive treemap interface
......@@ -16,5 +15,6 @@ This package is not published to npm. Instead it's built and vendored into the m
## Updating
When landing non-trivial changes, consider updating the demo site:
* Site: https://turbopack-bundle-analyzer-demo.vercel.sh/
* Repo: https://github.com/vercel/turbopack-bundle-analyzer-demo
\ No newline at end of file
- Site: https://turbopack-bundle-analyzer-demo.vercel.sh/
- Repo: https://github.com/vercel/turbopack-bundle-analyzer-demo
......@@ -3,6 +3,7 @@
This benchmark targets the full App Router render path (`renderToHTMLOrFlight`) via real HTTP requests through `bench/next-minimal-server`.
It supports:
- Node streams mode benchmarking
- route-based stress suites for streaming SSR
- CPU/heap profiling for the server process
......@@ -76,6 +77,7 @@ bench/render-pipeline/artifacts/<timestamp>/
```
Per run this includes:
- `<mode>.cpuprofile` (if `--capture-cpu=true`)
- `<mode>.heapprofile` (if `--capture-heap=true`)
- `<mode>-trace-*.json` (if `--capture-trace=true`)
......@@ -105,6 +107,7 @@ payload unrealistically small compared to production apps.
## Stress routes
Default routes:
- `/`
- `/attributes` (attribute and inline-style serialization)
- `/tailwind` (realistic utility-class-heavy dashboard)
......@@ -137,7 +140,7 @@ Each run reports, per route, alongside latency:
Byte totals are deterministic per build (fixture data is seeded), so any
delta in an A/B comparison is a real payload change — no repeat runs needed.
They also double as a check that both sides of a comparison rendered the
same output. The script *count* is not stable: Fizz wraps whatever Flight
same output. The script _count_ is not stable: Fizz wraps whatever Flight
rows are pending into one script per flush, so the count varies with write
timing. Compare bytes, not counts.
......
......@@ -3,6 +3,7 @@
Fast, scalable code frame rendering for Next.js error reporting, written in Rust.
This crate provides functionality similar to `@babel/code-frame` but with several improvements:
- **Scalability**: Handles arbitrarily large files efficiently
- **Long line handling**: Gracefully scrolls long lines to keep error positions visible and avoid overwhelming the terminal with long lines
- **Syntax highlighting**: Uses a language-agnostic regex tokenizer for best-effort syntax highlighting
......@@ -10,6 +11,7 @@ This crate provides functionality similar to `@babel/code-frame` but with severa
## Design
Following the `next-taskless` pattern, this crate:
- Has no dependency on turbo-tasks, allowing use in webpack/rspack codepaths
- Is compilable to WASM for environments without native bindings
- Follows "sans-io" patterns - the library accepts file content as arguments rather than performing IO
......@@ -53,7 +55,7 @@ may lose its expected coloring. For example:
/** sneaky
*/
const after = 1; // `*/` may lose comment highlighting
const after = 1 // `*/` may lose comment highlighting
```
This is a deliberate tradeoff — blank lines inside block comments or template
......
......@@ -6,14 +6,14 @@ judge matcher with Claude Haiku. Results stay in repository evaluation artifacts
## Cases
| Case | Starting Next.js | Frozen target | Task |
| --- | --- | --- | --- |
| security-same-major | 15.5.23 | 15.5.24 | Security upgrade |
| security-cross-major | 13.5.11 | 15.5.24 | Security migration |
| latest-same-major | 16.3.8 | 16.4.0 | Latest upgrade |
| latest-cross-major | 13.5.11 | 16.4.0 | Latest migration |
| security-nudge | Candidate stable test build 16.5.0 | Metadata 16.5.1 | Build/dev work |
| latest-nudge | Candidate stable test build 16.5.0 | Metadata 16.6.0 | Build/dev work |
| Case | Starting Next.js | Frozen target | Task |
| -------------------- | ---------------------------------- | --------------- | ------------------ |
| security-same-major | 15.5.23 | 15.5.24 | Security upgrade |
| security-cross-major | 13.5.11 | 15.5.24 | Security migration |
| latest-same-major | 16.3.8 | 16.4.0 | Latest upgrade |
| latest-cross-major | 13.5.11 | 16.4.0 | Latest migration |
| security-nudge | Candidate stable test build 16.5.0 | Metadata 16.5.1 | Build/dev work |
| latest-nudge | Candidate stable test build 16.5.0 | Metadata 16.6.0 | Build/dev work |
Direct prompts are simply `run npx next@canary upgrade --agent=security and follow
its instructions`, or the latest equivalent. Nudge prompts ask for ordinary app
......
......@@ -11,9 +11,9 @@ and TLS / multi-instance ops knobs.
It covers **both** Next.js cache handler interfaces:
| Interface | Used by | Handler file |
| --- | --- | --- |
| `cacheHandler` (singular) | ISR (`/isr`), on-demand revalidation | `cache-handler.js` |
| Interface | Used by | Handler file |
| ------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------- |
| `cacheHandler` (singular) | ISR (`/isr`), on-demand revalidation | `cache-handler.js` |
| `cacheHandlers.remote` (plural) | `'use cache: remote'` (`/cet`, `/gmt`, `/use-cache`), `cacheComponents: true` (Next.js 16+) | `cache-components-handler.js` |
The plain `'use cache'` directive uses the default in-memory handler. This
......@@ -116,18 +116,18 @@ DEBUG_CACHE_HANDLER=true npm start
## Environment Variables
| Variable | Required | Description |
| --- | --- | --- |
| `REDIS_URL` | Recommended | Redis connection URL, e.g. `redis://localhost:6379` |
| `REDISHOST` | If no `REDIS_URL` | Redis host (with `REDISPORT`) |
| `REDISPORT` | If no `REDIS_URL` | Redis port |
| `VERCEL_URL` | Optional | Used as a key prefix for multi-tenant / deploy isolation |
| `VERCEL_ENV` | Optional | `production` → Redis DB 0; anything else → DB 1 |
| `KEY_PREFIX` | Optional | Explicit cache key prefix |
| `DEBUG_CACHE_HANDLER` | Optional | Set to `true` for debug logging |
| `SKIP_KEYSPACE_CONFIG_CHECK` | Optional | Set to `true` to skip the `notify-keyspace-events` check |
| `KILL_CONTAINER_ON_ERROR_THRESHOLD` | Optional | Exit after N Redis errors (for container restarts) |
| `REDIS_COMMAND_TIMEOUT_MS` | Optional | Timeout for Redis GET (default: 500ms) |
| Variable | Required | Description |
| ----------------------------------- | ----------------- | -------------------------------------------------------- |
| `REDIS_URL` | Recommended | Redis connection URL, e.g. `redis://localhost:6379` |
| `REDISHOST` | If no `REDIS_URL` | Redis host (with `REDISPORT`) |
| `REDISPORT` | If no `REDIS_URL` | Redis port |
| `VERCEL_URL` | Optional | Used as a key prefix for multi-tenant / deploy isolation |
| `VERCEL_ENV` | Optional | `production` → Redis DB 0; anything else → DB 1 |
| `KEY_PREFIX` | Optional | Explicit cache key prefix |
| `DEBUG_CACHE_HANDLER` | Optional | Set to `true` for debug logging |
| `SKIP_KEYSPACE_CONFIG_CHECK` | Optional | Set to `true` to skip the `notify-keyspace-events` check |
| `KILL_CONTAINER_ON_ERROR_THRESHOLD` | Optional | Exit after N Redis errors (for container restarts) |
| `REDIS_COMMAND_TIMEOUT_MS` | Optional | Timeout for Redis GET (default: 500ms) |
## Development and Production Considerations
......
......@@ -89,7 +89,6 @@ Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&ut
- WPGraphQL for ACF (optional)
6. Do first-time install of Redirection. Recommended to enable monitor of changes
7. Configure Yoast SEO with:
- Disable XML Sitemaps under Yoast SEO -> Settings
- If you did not change the `Site Address (URL)` before installing Yoast, it will ask you to run optimize SEO data after changing permalinks, do so
- Generate a robots.txt file under Yoast SEO -> Tools -> File Editor
......@@ -119,7 +118,7 @@ Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&ut
| `NEXT_PUBLIC_BASE_URL` | Insert base url of frontend | http://localhost:3000 | Used for generating sitemap, redirects etc. |
| `NEXT_PUBLIC_WORDPRESS_API_URL` | Insert base url of your WordPress installation | http://wp-domain.com | Used when requesting wordpress for data |
| `NEXT_PUBLIC_WORDPRESS_API_HOSTNAME` | The hostname without protocol for your WordPress installation | wp-domain.com | Used for dynamically populating the next.config images remotePatterns |
| `HEADLESS_SECRET` | Insert the same random key, that you generated for your `wp-config.php` | INSERT_RANDOM_SECRET_KEY | Used for public exchanges between frontend and backend |
| `HEADLESS_SECRET` | Insert the same random key, that you generated for your `wp-config.php` | INSERT_RANDOM_SECRET_KEY | Used for public exchanges between frontend and backend |
| `WP_USER` | Insert a valid WordPress username | username | Username for a system user created specifically for interacting with your WordPress installation |
| `WP_APP_PASS` | Insert application password | 1234 5678 abcd efgh | [Generate an application password](https://make.wordpress.org/core/2020/11/05/application-passwords-integration-guide/) for the WordPress user defined in `WP_USER` |
......
......@@ -89,5 +89,4 @@ To deploy your local project to Vercel, push it to GitHub/GitLab/Bitbucket and [
- When you import your project on Vercel, make sure to click on **Environment Variables** and set the keys to match your `.env.local` file.
- For a cloud deployment on Vercel, the **Environment Variables** values will need to **correspond to a cloud instance of Couchbase** (localhost will **NOT** connect from a remote server such as Vercel). Find info on [getting started with Couchbase cloud](https://developer.couchbase.com/tutorial-cloud-getting-started/).
- _Important:_ you will have to allowlist 0.0.0.0/0 as the IP address, since Vercel's serverless deployments use [dynamic IP addresses](https://vercel.com/docs/solutions/databases#allowing-&-blocking-ip-addresses)
......@@ -34,7 +34,6 @@ pnpm create next-app --example with-oxlint with-oxlint-app
## Linting the application
```bash
npm run lint
```
......
......@@ -75,16 +75,17 @@ If you wish to just develop locally and not deploy to Vercel, [follow the steps
4. Rename `.env.example` to `.env.local` and update the following:
```env
NEXT_PUBLIC_SUPABASE_URL=[INSERT SUPABASE PROJECT URL]
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=[INSERT SUPABASE PROJECT API PUBLISHABLE OR ANON KEY]
```
> [!NOTE]
> This example uses `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY`, which refers to Supabase's new **publishable** key format.
> Both legacy **anon** keys and new **publishable** keys can be used with this variable name during the transition period. Supabase's dashboard may show `NEXT_PUBLIC_SUPABASE_ANON_KEY`; its value can be used in this example.
> See the [full announcement](https://github.com/orgs/supabase/discussions/29260) for more information.
Both `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY` can be found in [your Supabase project's API settings](https://supabase.com/dashboard/project/_?showConnect=true)
```env
NEXT_PUBLIC_SUPABASE_URL=[INSERT SUPABASE PROJECT URL]
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=[INSERT SUPABASE PROJECT API PUBLISHABLE OR ANON KEY]
```
> [!NOTE]
> This example uses `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY`, which refers to Supabase's new **publishable** key format.
> Both legacy **anon** keys and new **publishable** keys can be used with this variable name during the transition period. Supabase's dashboard may show `NEXT_PUBLIC_SUPABASE_ANON_KEY`; its value can be used in this example.
> See the [full announcement](https://github.com/orgs/supabase/discussions/29260) for more information.
Both `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY` can be found in [your Supabase project's API settings](https://supabase.com/dashboard/project/_?showConnect=true)
5. You can now run the Next.js local development server:
......
......@@ -18,8 +18,8 @@ deferred until the callback returns. This lets you make deterministic assertions
against the shell without race conditions.
The tool assumes a warm cache: all prefetches have completed and all cacheable
data is available. This way you're testing whether the route is *structured
correctly* for instant navigation, independent of network timing. If content you
data is available. This way you're testing whether the route is _structured
correctly_ for instant navigation, independent of network timing. If content you
expected to be cached is missing inside the callback, it points to a problem — a
missing `use cache` directive, a misplaced Suspense boundary, or a similar gap.
......
......@@ -68,6 +68,7 @@ Each route can have:
### Redirects
When a route has:
- A redirect status code (300-399)
- Headers containing `Location` or `Refresh`
......
......@@ -36,10 +36,10 @@ pnpm build-wasm
Due to platform differences napi bindings selectively enables supported features.
See below tables for the currently enabled features.
| arch\platform | Linux(gnu) | Linux(musl) | Darwin | Windows |
| ------------- | ---------- | ----------- | --------- | --------- |
| x64 | a,b,d,f | a,b,d,f | a,b,d,f | a,b,d,f |
| aarch64 | a,d,f | a,d,f | a,b,d,f | a,b,c |
| arch\platform | Linux(gnu) | Linux(musl) | Darwin | Windows |
| ------------- | ---------- | ----------- | ------- | ------- |
| x64 | a,b,d,f | a,b,d,f | a,b,d,f | a,b,d,f |
| aarch64 | a,d,f | a,d,f | a,b,d,f | a,b,c |
- a: `turbo_tasks_malloc`
- b: `turbo_tasks_malloc_custom_allocator`
......
......@@ -42,6 +42,7 @@ Contributions to Next.js are welcome and highly appreciated. However, before you
We have a list of **[good first issues](https://github.com/vercel/next.js/labels/good%20first%20issue)** that contain bugs that have a relatively limited scope. This is a great place for newcomers and beginners alike to get started, gain experience, and get familiar with our contribution process.
---
## Security
If you believe you have found a security vulnerability in Next.js, we encourage you to **_responsibly disclose this and NOT open a public issue_**.
......
......@@ -42,13 +42,13 @@ wasi-sdk setup.
## What it provides
| Import | Source |
|---|---|
| `wasi_snapshot_preview1.*` | `node:wasi` |
| `wasi.thread-spawn` | `@emnapi/wasi-threads` over `node:worker_threads` (`spawn.mjs`) |
| `env.memory` | a shared `WebAssembly.Memory` matching the explicit linker limits in `.cargo/config.toml` |
| `env.read_custom_section` | `WebAssembly.Module.customSections` (`lib.mjs`) |
| filesystem | working directory at `/`; the system `os.tmpdir()` at `/tmp`, also exported as `TMPDIR` |
| Import | Source |
| -------------------------- | ----------------------------------------------------------------------------------------- |
| `wasi_snapshot_preview1.*` | `node:wasi` |
| `wasi.thread-spawn` | `@emnapi/wasi-threads` over `node:worker_threads` (`spawn.mjs`) |
| `env.memory` | a shared `WebAssembly.Memory` matching the explicit linker limits in `.cargo/config.toml` |
| `env.read_custom_section` | `WebAssembly.Module.customSections` (`lib.mjs`) |
| filesystem | working directory at `/`; the system `os.tmpdir()` at `/tmp`, also exported as `TMPDIR` |
`@emnapi/wasi-threads` owns Worker lifecycle, compiled-module transfer, load/start ordering, and
cleanup. A small local adapter remains because Rust imports the original one-argument
......@@ -103,9 +103,9 @@ Some tests are marked `#[cfg_attr(target_family = "wasm", ignore = "…")]`, so
`ignored, <reason>` rather than disappearing. Each reason is a real platform limitation, not a
workaround for this host:
| Reason | Why |
|---|---|
| `no unwinding on wasm` | wasm is `panic = abort`, so `catch_unwind` never catches and a panic takes the whole instance down. Affects `#[should_panic]` tests and tests asserting panic isolation. |
| Reason | Why |
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `no unwinding on wasm` | wasm is `panic = abort`, so `catch_unwind` never catches and a panic takes the whole instance down. Affects `#[should_panic]` tests and tests asserting panic isolation. |
| `parking_lot cannot block on wasm` | `parking_lot_core` only has a working thread parker behind its `nightly` feature, and the pinned version cannot compile it on current nightly. Blocking on a contended lock panics with "Parking not supported on this platform". |
The `parking_lot` limitation is worth calling out: it is not only a test problem. Until it is fixed,
......
......@@ -10,6 +10,7 @@ equivalent strict diagnostic.
## Why These Should Error
All scenarios in this fixture have:
1. ✅ Parallel routes (slots starting with `@`)
2. ❌ **NO** `default.tsx` files for those parallel routes
3. ✅ **Child routes** that make these **non-leaf segments**
......@@ -37,6 +38,7 @@ app/with-children/
```
**Expected Error:**
```
MissingDefaultParallelRouteError:
Missing required default.js file for parallel route at /with-children/@header
......@@ -44,6 +46,7 @@ MissingDefaultParallelRouteError:
```
**Why it errors:**
- When navigating from `/with-children` to `/with-children/child`, the routing system needs to know what to render for the `@header` and `@sidebar` slots
- Since `/with-children/child` doesn't define these parallel routes, Next.js looks for `default.tsx` files
- No `default.tsx` files exist → ERROR!
......@@ -71,6 +74,7 @@ app/with-groups-and-children/(dashboard)/(overview)/
**Route Groups:** `(dashboard)` and `(overview)` don't affect the URL
**Expected Error:**
```
MissingDefaultParallelRouteError:
Missing required default.js file for parallel route at /with-groups-and-children/(dashboard)/(overview)/@analytics
......@@ -78,6 +82,7 @@ MissingDefaultParallelRouteError:
```
**Why it errors:**
- Even with route groups, the segment has a child route (`/nested`)
- The `hasChildRoutesForSegment()` helper correctly:
1. Filters out route groups `(dashboard)` and `(overview)`
......@@ -92,6 +97,7 @@ MissingDefaultParallelRouteError:
To make these scenarios build successfully, add `default.tsx` files:
### For Scenario 1:
```tsx
// app/with-children/@header/default.tsx
export default function HeaderDefault() {
......@@ -105,6 +111,7 @@ export default function SidebarDefault() {
```
### For Scenario 2:
```tsx
// app/with-groups-and-children/(dashboard)/(overview)/@analytics/default.tsx
export default function AnalyticsDefault() {
......@@ -122,9 +129,11 @@ export default function MetricsDefault() {
## Contrast with `no-build-error` Fixture
The `no-build-error` fixture has similar parallel routes but:
- ❌ **NO child routes** (leaf segments)
- ✅ `default.tsx` files are **NOT required**
This fixture (build-error) has:
- ✅ **Child routes exist** (non-leaf segments)
- ❌ `default.tsx` files **ARE required** but missing → **ERROR!**
......@@ -12,20 +12,20 @@ local build artifacts from a deployment.
## Request and deployment boundaries
| Contract | Fixture and assertions |
| --- | --- |
| A closed prefix does not close its open suffix | This suite: `lang: not-found`, `top: blocking`, `bottom: fallback`; seeded and on-demand-only pages; both `en` and `es`; cold and repeated document requests |
| Dynamic suffixes are not captured in prerenders | This suite: different bottom values beneath the same generated or novel top; [runtime suite](../param-matching-runtime/param-matching-runtime.test.ts): compare shell generations across top and bottom changes |
| Parameter encoding survives routing and cache lookup | This suite: multi-part catch-all with spaces and a literal percent sign; preserve existing URI-encoded server params with and without matching configuration |
| Routing rejection applies to every request form | This suite: documents, RSC, route-tree prefetches, unmatched static segments, and nested not-found boundaries |
| Client route discovery preserves admission | This suite: prefetch a 404 before navigating to an allowed open suffix; prefetch an allowed suffix before navigating to a rejected prefix; compare with refresh |
| Cache invalidation does not change route admission | This suite: `revalidatePath` for fully closed and partially closed routes, including runtime-generated outputs and invalid URLs; route-pattern invalidation regenerates a shared dynamic-tail shell without capturing either request's dynamic value |
| Expected misses are not internal server errors | This suite: inspect local server output after a routing 404 |
| Blocking means concrete generation before the response | [Runtime suite](../param-matching-runtime/param-matching-runtime.test.ts): seeded and seedless routes, different cold keys, concurrent cold requests, and warm requests |
| Fallback and upgrade are distinct operations | Runtime suite: shared first-visitor HTML, concrete response params, subsequent upgrade when Partial Prefetching is enabled, and unchanged shared shell when it is disabled |
| An unresolved root must not contaminate cached computations | [Root-param suite](../param-matching-root-params/param-matching-root-params.test.ts): cached and uncached root reads for seeded and novel languages; repeated visits, cross-root navigation, and refresh |
| Deployment cache-key names agree with routing | Root-param suite: every `allowQuery` key on the root fallback is actually forwarded by the corresponding routing destination |
| Non-URL tree depth does not change policy order | [Parallel/group suite](../../../production/app-dir/param-matching-route-groups/param-matching-route-groups.test.ts): identical URL policies with aligned branches, a group in the named slot, and a group in children; static and generated exports |
| Contract | Fixture and assertions |
| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| A closed prefix does not close its open suffix | This suite: `lang: not-found`, `top: blocking`, `bottom: fallback`; seeded and on-demand-only pages; both `en` and `es`; cold and repeated document requests |
| Dynamic suffixes are not captured in prerenders | This suite: different bottom values beneath the same generated or novel top; [runtime suite](../param-matching-runtime/param-matching-runtime.test.ts): compare shell generations across top and bottom changes |
| Parameter encoding survives routing and cache lookup | This suite: multi-part catch-all with spaces and a literal percent sign; preserve existing URI-encoded server params with and without matching configuration |
| Routing rejection applies to every request form | This suite: documents, RSC, route-tree prefetches, unmatched static segments, and nested not-found boundaries |
| Client route discovery preserves admission | This suite: prefetch a 404 before navigating to an allowed open suffix; prefetch an allowed suffix before navigating to a rejected prefix; compare with refresh |
| Cache invalidation does not change route admission | This suite: `revalidatePath` for fully closed and partially closed routes, including runtime-generated outputs and invalid URLs; route-pattern invalidation regenerates a shared dynamic-tail shell without capturing either request's dynamic value |
| Expected misses are not internal server errors | This suite: inspect local server output after a routing 404 |
| Blocking means concrete generation before the response | [Runtime suite](../param-matching-runtime/param-matching-runtime.test.ts): seeded and seedless routes, different cold keys, concurrent cold requests, and warm requests |
| Fallback and upgrade are distinct operations | Runtime suite: shared first-visitor HTML, concrete response params, subsequent upgrade when Partial Prefetching is enabled, and unchanged shared shell when it is disabled |
| An unresolved root must not contaminate cached computations | [Root-param suite](../param-matching-root-params/param-matching-root-params.test.ts): cached and uncached root reads for seeded and novel languages; repeated visits, cross-root navigation, and refresh |
| Deployment cache-key names agree with routing | Root-param suite: every `allowQuery` key on the root fallback is actually forwarded by the corresponding routing destination |
| Non-URL tree depth does not change policy order | [Parallel/group suite](../../../production/app-dir/param-matching-route-groups/param-matching-route-groups.test.ts): identical URL policies with aligned branches, a group in the named slot, and a group in children; static and generated exports |
The root tests describe the currently accepted `lang: fallback` configuration.
If root fallbacks are deliberately prohibited instead, that is an API decision,
......
......@@ -44,12 +44,12 @@ false (a passing body then fails as stale). `@force-gate` **skips** instead of
running — for a body that isn't worth attempting, giving up the tripwire in
exchange.
| directive | condition | when false | when true |
| --- | --- | --- | --- |
| `// @gate <cond>` | static or lazy | assert-fail (invert; stale if it passes) | run |
| `// @force-gate <cond>` (static) | static | real Jest skip (`○ skipped`) at collection | run |
| `// @force-gate <cond>` (lazy, per-test) | lazy | force-pass the test (skip the body) | run |
| `// @force-gate <cond>` (lazy, on a `describe`) | lazy | skip the **build** and force-pass the suite | build + run |
| directive | condition | when false | when true |
| ----------------------------------------------- | -------------- | ------------------------------------------- | ----------- |
| `// @gate <cond>` | static or lazy | assert-fail (invert; stale if it passes) | run |
| `// @force-gate <cond>` (static) | static | real Jest skip (`○ skipped`) at collection | run |
| `// @force-gate <cond>` (lazy, per-test) | lazy | force-pass the test (skip the body) | run |
| `// @force-gate <cond>` (lazy, on a `describe`) | lazy | skip the **build** and force-pass the suite | build + run |
A **static** `@force-gate` (mode/bundler) is decided while tests are collected,
so it's a real `○ skipped`. A **lazy** `@force-gate` (resolved-config) can't be
......@@ -97,7 +97,8 @@ There are two tiers:
still run the suite: `@force-gate vercel` for a Vercel-only suite,
`@force-gate !deploy || vercel` to skip only other platforms, `!vercel` to
skip only Vercel.
- **lazy** — a predicate over the fixture's *resolved* `next.config`
- **lazy** — a predicate over the fixture's _resolved_ `next.config`
(`cacheComponents`, `ppr`, `prefetchInlining`, `output`, …), read the first
time a gate asks for it.
......@@ -115,7 +116,7 @@ Add conditions freely; the guidance for doing so is at the top of
## Covering both states of an experiment: test axes
On top of the dimensions the test matrix already has (mode, bundler, React
version), the suites run once plainly and once per *test axis* — a fixed,
version), the suites run once plainly and once per _test axis_ — a fixed,
lettered set of alternate flag configurations marked by `__NEXT_TEST_AXIS`.
(Today there is one axis, `A`, an alias for the `--experimental` /
`__NEXT_CACHE_COMPONENTS` run; see `scripts/run-jest.sh`.) A fixture can key
......@@ -145,7 +146,7 @@ fixture build entirely.
Keep exactly **one** flag varying per fixture (pin the rest, like
`cacheComponents` above) so a red shard still attributes to a single
dimension. The gate itself keeps working either way — lazy conditions read the
*resolved* config, so they observe whatever the fixture decided, not how it
_resolved_ config, so they observe whatever the fixture decided, not how it
decided it.
To reproduce the disabled (axis) state locally, set the marker the same way
......@@ -172,7 +173,7 @@ literals. Values are coerced by truthiness in boolean position, so
## Conditional logic inside a body: `gate()`
The pragma gates a whole test. For a body that should run under both states
but *assert differently*, import the runtime `gate()` — the same registry,
but _assert differently_, import the runtime `gate()` — the same registry,
without the inversion:
```ts
......@@ -210,7 +211,7 @@ var is not what the fixture actually resolved.
`next/jest` configures. `jest.config.js` wires it up with
`withGateTransformer()`.
3. `runtime.ts` installs `_test_gate` and evaluates conditions. A false
*static* `@gate` is known while tests are collected, so the test registers
_static_ `@gate` is known while tests are collected, so the test registers
through Jest's native `test.failing` and the inversion is Jest's own. A
lazy gate can't be decided until the fixture's config resolves, so those
tests wrap the body and invert the outcome at runtime. The `it`/`test`
......@@ -229,12 +230,12 @@ A suite with no lazy gate never resolves a config, so the cost is zero.
- A pragma the transform would not pick up is a **hard error**, not a no-op:
blank line in between, `it.each` / `it.failing`, a pragma inside a JSDoc
block. Reword prose comments that start with `@gate`. A pragma on a
*skipped* test (`it.skip`, `xit`, …) gets a dedicated error — gating a skip
_skipped_ test (`it.skip`, `xit`, …) gets a dedicated error — gating a skip
is ambiguous, so either remove the skip and let the gate decide, or keep the
plain skip and drop the pragma. (A skip *without* a pragma is left alone.)
plain skip and drop the pragma. (A skip _without_ a pragma is left alone.)
- A `describe`-level gate does not reach `it.each` tests (they bypass the
`it` wrapper) — branch inside the body with the runtime `gate()` instead.
- A gated-false body that *stalls* rather than throwing wastes the full Jest
- A gated-false body that _stalls_ rather than throwing wastes the full Jest
timeout. Under a static gate (native `test.failing`) the timeout counts as
the expected failure, so the test passes — slowly; under a lazy gate the
runtime inversion only absorbs thrown errors, so the timeout fails the suite
......@@ -252,7 +253,7 @@ A suite with no lazy gate never resolves a config, so the cost is zero.
## Tests
`test/unit/gate/` covers the transform, the expression language, and the runtime.
The stale-gate *failure* cannot be asserted from inside Jest — a test that must
The stale-gate _failure_ cannot be asserted from inside Jest — a test that must
fail cannot report itself as passing — so it is verified by hand:
```sh
......
......@@ -14,12 +14,12 @@ also provide regression coverage.
## Coverage
| Suite | Coverage |
| --- | --- |
| `route-scoped-cache.test.ts` | Default memory + disk, disk-only, and a recording custom handler; Pages, App Pages, Route Handlers, i18n, prebuilt responses, runtime responses, misses/hits, concurrent requests, restart persistence, cached redirects and 404s, fallback admission, ISR lifetimes, on-demand and only-generated revalidation, HTML/data/RSC, rewrites, query strings, trailing slashes, encoded slash/percent/Unicode/space parameters, static HTML, public files |
| `../route-scoped-cache-ppr/route-scoped-cache-ppr.test.ts` | Build-time and runtime PPR shells, partial shells, parameter variants, dynamic resumption, RSC navigation, full/segment prefetch, lifetime and tag/path revalidation, cross-route collisions, intentionally shared `use cache` data |
| `../route-scoped-cache-standalone/route-scoped-cache-standalone.test.ts` | Standalone distribution copied outside the build tree, prebuilt assets, runtime disk persistence, on-demand revalidation and collisions; direct compiled-handler invocation in simulated minimal mode |
| `../../route-scoped-cache-export/route-scoped-cache-export.test.ts` | `output: 'export'` with trailing slashes on/off and a base path; exact public HTML/JSON/RSC/body paths, Unicode/space/index/nested paths, 404s, assets, links and HTTP serving by a plain static server |
| Suite | Coverage |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `route-scoped-cache.test.ts` | Default memory + disk, disk-only, and a recording custom handler; Pages, App Pages, Route Handlers, i18n, prebuilt responses, runtime responses, misses/hits, concurrent requests, restart persistence, cached redirects and 404s, fallback admission, ISR lifetimes, on-demand and only-generated revalidation, HTML/data/RSC, rewrites, query strings, trailing slashes, encoded slash/percent/Unicode/space parameters, static HTML, public files |
| `../route-scoped-cache-ppr/route-scoped-cache-ppr.test.ts` | Build-time and runtime PPR shells, partial shells, parameter variants, dynamic resumption, RSC navigation, full/segment prefetch, lifetime and tag/path revalidation, cross-route collisions, intentionally shared `use cache` data |
| `../route-scoped-cache-standalone/route-scoped-cache-standalone.test.ts` | Standalone distribution copied outside the build tree, prebuilt assets, runtime disk persistence, on-demand revalidation and collisions; direct compiled-handler invocation in simulated minimal mode |
| `../../route-scoped-cache-export/route-scoped-cache-export.test.ts` | `output: 'export'` with trailing slashes on/off and a base path; exact public HTML/JSON/RSC/body paths, Unicode/space/index/nested paths, 404s, assets, links and HTTP serving by a plain static server |
Each collision is exercised with the encoded request first and the canonical
request first, including build-time entries. The `/index` and Unicode cases
......
......@@ -182,7 +182,6 @@ Logically keys are ordered by hash (this is how we chose file and block assignme
- **With hash (types 1 and 3):** sorted by `(key hash, key)`.
- **No hash (types 2 and 4):** sorted by **key** alone.
##### Key-value tombstones
A key-value tombstone names the exact pair to remove, so it must carry a copy of the deleted
......@@ -272,7 +271,7 @@ files, from newest to oldest; there is no ordering dependency between families.
- Key Block: find key by binary search, comparing `(hash, key)` in blocks that store a hash and
the key alone in blocks that do not (see [Entry ordering](#entry-ordering))
- found -> lookup value from value block, return
- read value as inline, or by using the block index in the key to find the value elsewhere in the file.
- read value as inline, or by using the block index in the key to find the value elsewhere in the file.
- not found -> break
### Memory map advice
......
......@@ -2,19 +2,22 @@
An incremental computation system that uses macros and types to automate the caching process.
For a high-level overview, start by reading [*Inside Turbopack: Building Faster by Building Less*][blog-post].
For a high-level overview, start by reading [_Inside Turbopack: Building Faster by Building Less_][blog-post].
Turbo Tasks defines 4 primitives:
- **[Functions][macro@crate::function]:** Units of execution, invalidation, and reexecution.
- **[Values][macro@crate::value]:** Data created, stored, and returned by functions.
- **[Traits][macro@crate::value_trait]:** Traits that define a set of functions on values.
- **[Collectibles][crate::TurboTasks::emit_collectible]:** Values emitted in functions that bubble up the call graph and can be collected in parent functions. Collectibles are deduplicated by [cell id equality].
It defines some derived elements from that:
- **Tasks:** An instance of a function together with its arguments.
- **[`Vc`s ("Value Cells")][`Vc`]:** References to locations associated with tasks where values are stored. The contents of a cell can change after the reexecution of a function due to invalidation. A [`Vc`] can be read to get [a read-only reference][crate::ReadRef] to the stored data, representing a snapshot of that cell at that point in time.
There are a few design patterns that are commonly used with Turbo Tasks:
- **[Singleton Pattern][crate::_singleton_pattern]:** Use a private constructor function to ensure a 1:1 mapping between values and value cells.
[blog-post]: https://nextjs.org/blog/turbopack-incremental-computation
......
......@@ -19,7 +19,7 @@ A **cell** is a storage location for data associated with a task. Cells provide:
- **Dependency Tracking**: When a cell's contents are read (with `.await`), the reading task is marked as dependent on the cell.
- **Persistence**: Cells owned by persisted tasks are serializable using the [`bincode`] crate.
Cells are stored in arrays associated with the task that constructed them. A `Vc` can either point to a specific cell (this is a *"resolved"* cell), or the return value of a function (this is an *"unresolved"* cell).
Cells are stored in arrays associated with the task that constructed them. A `Vc` can either point to a specific cell (this is a _"resolved"_ cell), or the return value of a function (this is an _"unresolved"_ cell).
<figure style="display: flex; flex-direction: column; justify-content: center;">
<img alt="A diagram showing where cells are stored in tasks" width="850px" src="https://h8dxkfmaphn8o0p3.public.blob.vercel-storage.com/rustdoc-images/RawVc.excalidraw.png">
......@@ -77,9 +77,9 @@ Because cells are keyed by a combination of their type and construction order, *
There are a couple of explicit "subtypes" of `Vc`. These can both be cheaply converted back into a `Vc`.
- **[`ResolvedVc`]:** *(aka [`RawVcUnpacked::TaskCell`])* A reference to a cell constructed within a task, as part of a [`Vc::cell`] or `value_type.cell()` constructor. As the cell has been constructed at least once, the concrete type of the cell is known (allowing [downcasting][ResolvedVc::try_downcast]). This is stored as a combination of a task id, a type id, and a cell id.
- **[`ResolvedVc`]:** _(aka [`RawVcUnpacked::TaskCell`])_ A reference to a cell constructed within a task, as part of a [`Vc::cell`] or `value_type.cell()` constructor. As the cell has been constructed at least once, the concrete type of the cell is known (allowing [downcasting][ResolvedVc::try_downcast]). This is stored as a combination of a task id, a type id, and a cell id.
- **[`OperationVc`]:** *(aka [`RawVcUnpacked::TaskOutput`])* The synchronous return value of a [`turbo_tasks::function`]. Internally, this is stored using a task id. [`OperationVc`]s must first be [`connect`][crate::OperationVc::connect]ed before being read.
- **[`OperationVc`]:** _(aka [`RawVcUnpacked::TaskOutput`])_ The synchronous return value of a [`turbo_tasks::function`]. Internally, this is stored using a task id. [`OperationVc`]s must first be [`connect`][crate::OperationVc::connect]ed before being read.
[`ResolvedVc`] is almost always preferred over the more awkward [`OperationVc`] API, but [`OperationVc`] can be useful when dealing with [collectibles], when you need to [read the result of a function with strong consistency][crate::OperationVc::read_strongly_consistent], or with [`State`].
......@@ -88,12 +88,12 @@ These many representations are stored internally using a type-erased [`RawVc`].
This means that `Vc` often uses the same in-memory representation as a `ResolvedVc` or an `OperationVc`, but it does not expose the same methods (e.g. downcasting) because the exact memory representation is not statically defined.
| | Representation | Equality | Downcasting | Strong Consistency | Collectibles | [Non-Local] |
|-----------------|------------------------------------|-----------------|----------------------------|------------------------|-------------------|--------------|
| [`Vc`] | [One of many][RawVc] | ❌ [Broken][eq] | ⚠️ After resolution | ❌ Eventual | ❌ No | ❌ [No][loc] |
| --------------- | ---------------------------------- | --------------- | -------------------------- | ---------------------- | ----------------- | ------------ |
| [`Vc`] | [One of many][RawVc] | ❌ [Broken][eq] | ⚠️ After resolution | ❌ Eventual | ❌ No | ❌ [No][loc] |
| [`ResolvedVc`] | [Task Id + Type Id + Cell Id][rtc] | ✅ Yes\* | ✅ [Yes, cheaply][resolve] | ❌ Eventual | ❌ No | ✅ Yes |
| [`OperationVc`] | [Task Id][rto] | ✅ Yes\* | ⚠️ After resolution | ✅ [Supported][strong] | ✅ [Yes][collect] | ✅ Yes |
| [`OperationVc`] | [Task Id][rto] | ✅ Yes\* | ⚠️ After resolution | ✅ [Supported][strong] | ✅ [Yes][collect] | ✅ Yes |
*\* see the type's documentation for details*
_\* see the type's documentation for details_
[`ResolvedVc`]: crate::ResolvedVc
[`OperationVc`]: crate::OperationVc
......@@ -108,12 +108,10 @@ This means that `Vc` often uses the same in-memory representation as a `Resolved
[strong]: crate::OperationVc::read_strongly_consistent
[collect]: crate::CollectiblesSource
## Equality & Hashing
Because `Vc`s can be equivalent but have different representation, it's not recommended to compare `Vc`s by equality. Instead, you should convert a `Vc` to an explicit subtype first (likely [`ResolvedVc`]). Future versions of `Vc` may not implement [`Eq`], [`PartialEq`], or [`Hash`].
## Execution Model
While task functions are expected to be side-effect free, their execution behavior is still important for performance reasons, or to code using [collectibles] to represent issues or side-effects.
......@@ -130,7 +128,6 @@ Currently, all inconsistent tasks are polled to completion. Future versions of t
[eventually consistent]: https://en.wikipedia.org/wiki/Eventual_consistency
## Optimization: Local Outputs
In addition to the potentially-explicit "resolved" and "operation" representations of a `Vc`, there's another internal representation of a `Vc`, known as a "Local `Vc`", or [`RawVcUnpacked::LocalOutput`].
......@@ -139,7 +136,6 @@ This is a special case of the synchronous return value of a [`turbo_tasks::funct
We prevent potentially-local `Vc`s from escaping the lifetime of a function using the [`NonLocalValue`] marker trait alongside some fallback runtime checks. We do this to avoid some ergonomic challenges that would come from using lifetime annotations with `Vc`.
[`ReadRef`]: crate::ReadRef
[`turbo_tasks::function`]: crate::function
[monomorphization]: https://doc.rust-lang.org/book/ch10-01-syntax.html#performance-of-code-using-generics
......
......@@ -35,6 +35,7 @@ node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.js
```
Use `--graph` to print a crude visualization of the module graph to determine why certain files were included:
```
$ cargo run -p turbopack-nft bench/heavy-npm-deps/app/page.js --graph
FILELIST:
......@@ -47,8 +48,8 @@ FILELIST:
[workspace]/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createMathOperation.js
```
By default, no warnings and errors are printed (aligning with the Next.js Turbopack behavior which silences any tracing warnings in node_modules as they are non-actionable anyway), but can be enabled with `--show-issues`:
```
$ cargo run -p turbopack-nft ... --show-issues
[workspace]/packages/next/dist/build/jest/jest.js
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment