Unverified Commit 108fe00f authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

fix: replace docs/canary links with stable docs paths in error messages (#92528)

### What?

Error messages for the `"use cache"` directive and `after()` API (in
`cookies()`, `headers()`, `connection()`) pointed to `/docs/canary/...`
instead of `/docs/...`.

### Why?

On canary builds, `docs/canary` links can create circular or confusing
references. These APIs are stable and their docs live at the standard
`/docs/app/...` path.

### How?

Replaced all `nextjs.org/docs/canary/` URLs with `nextjs.org/docs/` in:

- `crates/next-custom-transforms/src/transforms/server_actions.rs` — the
`"use cache"` feature flag error
-
`crates/next-custom-transforms/tests/errors/use-cache-not-allowed/1/output.stderr`
and `2/output.stderr` — matching test fixtures
- `packages/next/src/server/request/cookies.ts`, `headers.ts`,
`connection.ts` — `after()` errors
- `packages/next/errors.json` — compiled error message index (6
occurrences)

<!-- NEXT_JS_LLM_PR -->
parent de7ce396
......@@ -3942,7 +3942,7 @@ fn emit_error(error_kind: ServerActionsErrorKind) {
r#"
To use "{directive}", please enable the feature flag `cacheComponents` in your Next.js config.
Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
Read more: https://nextjs.org/docs/app/api-reference/directives/use-cache#usage
"#
},
),
......
x To use "use cache", please enable the feature flag `cacheComponents` in your Next.js config.
|
| Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
| Read more: https://nextjs.org/docs/app/api-reference/directives/use-cache#usage
|
,-[input.js:1:1]
1 | 'use cache'
......
x To use "use cache: x", please enable the feature flag `cacheComponents` in your Next.js config.
|
| Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
| Read more: https://nextjs.org/docs/app/api-reference/directives/use-cache#usage
|
,-[input.js:2:1]
1 | export default async function Page() {
......
......@@ -86,7 +86,7 @@
"85": "Invariant: Unexpected optional import %s",
"86": "Failed to set Next.js data cache, items over 2MB can not be cached (%s bytes)",
"87": "Page \"%s\" is missing \"generateStaticParams()\" so it cannot be used with \"output: export\" config.",
"88": "Route %s used \"cookies\" inside \"after(...)\". This is not supported. If you need this data inside an \"after\" callback, use \"cookies\" outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after",
"88": "Route %s used \"cookies\" inside \"after(...)\". This is not supported. If you need this data inside an \"after\" callback, use \"cookies\" outside of the callback. See more info here: https://nextjs.org/docs/app/api-reference/functions/after",
"89": "Image with src \"%s\" has \"placeholder='blur'\" property but is missing the \"blurDataURL\" property.\n Possible solutions:\n - Add a \"blurDataURL\" property, the contents should be a small Data URL to represent the image\n - Change the \"src\" property to a static import with one of the supported file types: %s (animated images not supported)\n - Remove the \"placeholder\" property, effectively no blur effect\n Read more: https://nextjs.org/docs/messages/placeholder-blur-data-url",
"90": "Failed to initialize render server",
"91": "`after()` will not work correctly, because `waitUntil` is not available in the current environment.",
......@@ -184,7 +184,7 @@
"183": "ImageResponse moved from \"next/server\" to \"next/og\" since Next.js 14, please import from \"next/og\" instead",
"184": "Dynamic WASM code generation (e. g. 'WebAssembly.compile') not allowed in Edge Runtime.\nLearn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation",
"185": "Invalid redirect object returned from %s for %s\\n%s\nSee more info here: https://nextjs.org/docs/messages/invalid-redirect-gssp",
"186": "Route %s used \"connection\" inside \"after(...)\". The \\`connection()\\` function is used to indicate the subsequent code must only run when there is an actual Request, but \"after(...)\" executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after",
"186": "Route %s used \"connection\" inside \"after(...)\". The \\`connection()\\` function is used to indicate the subsequent code must only run when there is an actual Request, but \"after(...)\" executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/after",
"187": "getStaticPaths is only allowed for dynamic SSG pages and was found on '%s'.\\nRead more: https://nextjs.org/docs/messages/non-dynamic-getstaticpaths-usage",
"188": "Next Image Optimization requires %s to be provided. Make sure you pass them as props to the \\`next/image\\` component. Received: %s",
"189": "Failed to load stylesheet: %s",
......@@ -365,7 +365,7 @@
"364": "invariant: Missing request body.",
"365": "Cannot subscribe to a closed CloseController",
"366": "invariant attempted to set non-image to image-cache",
"367": "Route %s used \"headers\" inside \"after(...)\". This is not supported. If you need this data inside an \"after\" callback, use \"headers\" outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after",
"367": "Route %s used \"headers\" inside \"after(...)\". This is not supported. If you need this data inside an \"after\" callback, use \"headers\" outside of the callback. See more info here: https://nextjs.org/docs/app/api-reference/functions/after",
"368": "Invariant might be excluded but missing source",
"369": "getServerSideProps cannot be used with \"output: export\". See more info here: https://nextjs.org/docs/advanced-features/static-html-export",
"370": "No Stats from webpack",
......@@ -825,7 +825,7 @@
"824": "URL is required in MCP browser response. This is a bug in Next.js.",
"825": "Timeout waiting for response from frontend. The browser may not be responding to HMR messages.",
"826": "unknown bundler: %s",
"827": "Route %s used \\`connection()\\` inside \\`after()\\`. The \\`connection()\\` function is used to indicate the subsequent code must only run when there is an actual Request, but \\`after()\\` executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after",
"827": "Route %s used \\`connection()\\` inside \\`after()\\`. The \\`connection()\\` function is used to indicate the subsequent code must only run when there is an actual Request, but \\`after()\\` executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/after",
"828": "Route %s with \\`dynamic = \"error\"\\` couldn't be rendered statically because it used \\`headers()\\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering",
"829": "Route %s used \"%s\" inside \"use cache\". The enabled status of \\`draftMode()\\` can be read in caches but you must not enable or disable \\`draftMode()\\` inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache",
"830": "%sused %s. \\`cookies()\\` returns a Promise and must be unwrapped with \\`await\\` or \\`React.use()\\` before accessing its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis",
......@@ -837,11 +837,11 @@
"836": "%sused %s. \\`headers()\\` returns a Promise and must be unwrapped with \\`await\\` or \\`React.use()\\` before accessing its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis",
"837": "Route %s used \\`connection()\\` inside \"use cache: private\". The \\`connection()\\` function is used to indicate the subsequent code must only run when there is an actual navigation request, but caches must be able to be produced before a navigation request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache",
"838": "Route %s used \\`headers()\\` inside a function cached with \\`unstable_cache()\\`. Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use \\`headers()\\` outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache",
"839": "Route %s used \\`headers()\\` inside \\`after()\\`. This is not supported. If you need this data inside an \\`after()\\` callback, use \\`headers()\\` outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after",
"839": "Route %s used \\`headers()\\` inside \\`after()\\`. This is not supported. If you need this data inside an \\`after()\\` callback, use \\`headers()\\` outside of the callback. See more info here: https://nextjs.org/docs/app/api-reference/functions/after",
"840": "Route %s used \\`connection()\\` inside a function cached with \\`unstable_cache()\\`. The \\`connection()\\` function is used to indicate the subsequent code must only run when there is an actual Request, but caches must be able to be produced before a Request so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache",
"841": "Route %s used \\`connection()\\` inside \"use cache\". The \\`connection()\\` function is used to indicate the subsequent code must only run when there is an actual request, but caches must be able to be produced before a request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache",
"842": "Route %s used \\`searchParams\\` inside \"use cache\". Accessing dynamic request data inside a cache scope is not supported. If you need some search params inside a cached function await \\`searchParams\\` outside of the cached function and pass only the required search params as arguments to the cached function. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache",
"843": "Route %s used \\`cookies()\\` inside \\`after()\\`. This is not supported. If you need this data inside an \\`after()\\` callback, use \\`cookies()\\` outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after",
"843": "Route %s used \\`cookies()\\` inside \\`after()\\`. This is not supported. If you need this data inside an \\`after()\\` callback, use \\`cookies()\\` outside of the callback. See more info here: https://nextjs.org/docs/app/api-reference/functions/after",
"844": "Route %s used \"%s\" inside a function cached with \\`unstable_cache()\\`. The enabled status of \\`draftMode()\\` can be read in caches but you must not enable or disable \\`draftMode()\\` inside a cache. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache",
"845": "Route %s used \"%s\" inside \\`after()\\`. The enabled status of \\`draftMode()\\` can be read inside \\`after()\\` but you cannot enable or disable \\`draftMode()\\`. See more info here: https://nextjs.org/docs/app/api-reference/functions/after",
"846": "Route %s used \\`cookies()\\` inside a function cached with \\`unstable_cache()\\`. Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use \\`cookies()\\` outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache",
......
......@@ -34,7 +34,7 @@ export function connection(): Promise<void> {
!isRequestAPICallableInsideAfter()
) {
throw new Error(
`Route ${workStore.route} used \`connection()\` inside \`after()\`. The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but \`after()\` executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after`
`Route ${workStore.route} used \`connection()\` inside \`after()\`. The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but \`after()\` executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`
)
}
......
......@@ -44,7 +44,7 @@ export function cookies(): Promise<ReadonlyRequestCookies> {
) {
throw new Error(
// TODO(after): clarify that this only applies to pages?
`Route ${workStore.route} used \`cookies()\` inside \`after()\`. This is not supported. If you need this data inside an \`after()\` callback, use \`cookies()\` outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after`
`Route ${workStore.route} used \`cookies()\` inside \`after()\`. This is not supported. If you need this data inside an \`after()\` callback, use \`cookies()\` outside of the callback. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`
)
}
......
......@@ -50,7 +50,7 @@ export function headers(): Promise<ReadonlyHeaders> {
!isRequestAPICallableInsideAfter()
) {
throw new Error(
`Route ${workStore.route} used \`headers()\` inside \`after()\`. This is not supported. If you need this data inside an \`after()\` callback, use \`headers()\` outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after`
`Route ${workStore.route} used \`headers()\` inside \`after()\`. This is not supported. If you need this data inside an \`after()\` callback, use \`headers()\` outside of the callback. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`
)
}
......
......@@ -34,7 +34,7 @@ describe('use-cache-without-experimental-flag', () => {
'To use "use cache", please enable the feature flag `cacheComponents` in your Next.js config.'
)
expect(buildOutput).toContain(
'Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage'
'Read more: https://nextjs.org/docs/app/api-reference/directives/use-cache#usage'
)
expect(buildOutput).toContain('Ecmascript file had an error')
expect(buildOutput).toContain('./app/page.tsx:1:1')
......@@ -46,7 +46,7 @@ describe('use-cache-without-experimental-flag', () => {
./app/page.tsx
╰─▶ × Error: x To use "use cache", please enable the feature flag \`cacheComponents\` in your Next.js config.
│ |
│ | Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
│ | Read more: https://nextjs.org/docs/app/api-reference/directives/use-cache#usage
│
│ ,-[1:1]
│ 1 | 'use cache'
......@@ -70,7 +70,7 @@ describe('use-cache-without-experimental-flag', () => {
./app/page.tsx
Error: x To use "use cache", please enable the feature flag \`cacheComponents\` in your Next.js config.
|
| Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
| Read more: https://nextjs.org/docs/app/api-reference/directives/use-cache#usage
,-[1:1]
1 | 'use cache'
......@@ -118,7 +118,7 @@ describe('use-cache-without-experimental-flag', () => {
'To use "use cache", please enable the feature flag `cacheComponents` in your Next.js config.'
)
expect(errorSource).toContain(
'Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage'
'Read more: https://nextjs.org/docs/app/api-reference/directives/use-cache#usage'
)
expect(errorSource).toContain("> 1 | 'use cache'")
expect(errorSource).toContain('Ecmascript file had an error')
......@@ -127,7 +127,7 @@ describe('use-cache-without-experimental-flag', () => {
"./app/page.tsx
╰─▶ × Error: x To use "use cache", please enable the feature flag \`cacheComponents\` in your Next.js config.
│ |
│ | Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
│ | Read more: https://nextjs.org/docs/app/api-reference/directives/use-cache#usage
│
│ ,-[1:1]
│ 1 | 'use cache'
......@@ -143,7 +143,7 @@ describe('use-cache-without-experimental-flag', () => {
"./app/page.tsx
Error: x To use "use cache", please enable the feature flag \`cacheComponents\` in your Next.js config.
|
| Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
| Read more: https://nextjs.org/docs/app/api-reference/directives/use-cache#usage
,-[1:1]
1 | 'use cache'
......
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