Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: error code system - #35429

#35429
Merged
danielroe merged 88 commits into
mainnuxt/nuxt:mainfrom
feat/nostics-errorsnuxt/nuxt:feat/nostics-errorsCopy head branch name to clipboard
Jul 18, 2026
Merged

feat: error code system#35429
danielroe merged 88 commits into
mainnuxt/nuxt:mainfrom
feat/nostics-errorsnuxt/nuxt:feat/nostics-errorsCopy head branch name to clipboard

Conversation

@posva

@posva posva commented Jun 24, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

Closes #34719

📚 Description

Initial migration of errors to nostics with stable code errors

TODO:

  • Remove or add more details to irrelevant doc pages: when the doc page doesn't add valuable content compared to the diagnostic why + fix
  • Verify no duplicated diagnostics exist
  • Make sure actual warnings or runtime errors not meant to be diagnostics, are kept as is
  • Verify the wording of all errors
  • Cleanup excessive commenting
  • Production stripping of why and fix

@posva
posva requested a review from danielroe as a code owner June 24, 2026 09:29
@github-actions github-actions Bot added 5.x ✨ enhancement New feature or improvement to existing functionality labels Jun 24, 2026
Comment thread docs/errors/b1003.md Outdated
@posva
posva force-pushed the feat/nostics-errors branch from 02c6f66 to 2b47a11 Compare June 29, 2026 13:55
@socket-security

socket-security Bot commented Jun 29, 2026

Copy link
Copy Markdown

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@coderabbitai

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 17

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/nuxt/src/components/plugins/lazy-hydration-transform.ts (1)

95-105: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Normalise the file path for NUXT_B3005.

Line 95 emits the raw transform id, while Line 105 already aliases the same file before reporting NUXT_B3006. That makes the new diagnostics environment-dependent and exposes absolute workspace paths for one warning but not the other.

Suggested fix
-          const components = new Set(options.getComponents().map(c => c.pascalName))
+          const components = new Set(options.getComponents().map(c => c.pascalName))
+          const file = nuxt ? resolveToAlias(id, nuxt) : id
           await walk(ast, (node) => {
@@
                 if (strategy) {
-                  componentDiagnostics.NUXT_B3005({ component: node.name, file: id })
+                  componentDiagnostics.NUXT_B3005({ component: node.name, file })
                 } else {
                   strategy = hydrationStrategyMap[prop as keyof typeof hydrationStrategyMap]
                 }
@@
             if (strategy && !/^(?:Lazy|lazy-)/.test(node.name)) {
               if (node.name !== 'template' && (nuxt?.options.dev || nuxt?.options.test)) {
-                const relativePath = resolveToAlias(id, nuxt)
-                componentDiagnostics.NUXT_B3006({ component: node.name, file: relativePath, lazyName: `Lazy${pascalCase(node.name)}` })
+                componentDiagnostics.NUXT_B3006({ component: node.name, file, lazyName: `Lazy${pascalCase(node.name)}` })
               }
               return
             }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nuxt/src/components/plugins/lazy-hydration-transform.ts` around
lines 95 - 105, Normalize the file path used by NUXT_B3005 in
lazy-hydration-transform so it matches the aliased path format already used for
NUXT_B3006. Update the componentDiagnostics.NUXT_B3005 call to pass
resolveToAlias(id, nuxt) (or an equivalent shared normalized value) instead of
the raw id, so both diagnostics report consistent, environment-independent file
references.
packages/nuxt/src/pages/plugins/page-meta.ts (1)

103-112: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Restore the throw on empty page-meta modules.

Line 107 now only reports NUXT_B4001 and then returns the fallback transform result. That turns a hard build-time failure into a log-only path, so empty ?macro=true modules can slip through with generated empty metadata instead of stopping the build.

Suggested fix
         if (!hasMacro && !code.includes('export { default }') && !code.includes('__nuxt_page_meta')) {
           if (!code) {
             s.append(options.dev ? (CODE_DEV_EMPTY + CODE_HMR) : CODE_EMPTY)
             const { pathname } = parseModuleId(id)
-            pageDiagnostics.NUXT_B4001({ pathname }, { method: 'error' })
+            throw pageDiagnostics.NUXT_B4001({ pathname })
           } else {
             s.overwrite(0, code.length, options.dev ? (CODE_DEV_EMPTY + CODE_HMR) : CODE_EMPTY)
           }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nuxt/src/pages/plugins/page-meta.ts` around lines 103 - 112, Restore
the hard failure path in page-meta handling: in the empty-module branch inside
the page transform logic, after `pageDiagnostics.NUXT_B4001` is emitted, throw
again instead of returning `result()`. Update the `page-meta.ts` flow around
`hasMacro`, `parseModuleId`, and `pageDiagnostics.NUXT_B4001` so empty
`?macro=true` modules still stop the build rather than continuing with the
fallback transform output.
🧹 Nitpick comments (1)
packages/nuxt/src/app/composables/asyncData.ts (1)

400-420: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the emitting helper in NUXT_E3004.

Line 420 now only reports the key and warning list, so the duplicate-options warning is harder to trace back than before. You already carry _functionName through dev-only async-data options, so please pass it into this diagnostic and include it in the template as well.

Possible follow-up
-          dataDiagnostics.NUXT_E3004({ key: key.value, warnings: warnings.map(w => `- ${w}`).join('\n') })
+          dataDiagnostics.NUXT_E3004({
+            key: key.value,
+            fn: opts._functionName || 'useAsyncData',
+            warnings: warnings.map(w => `- ${w}`).join('\n'),
+          })
// packages/nuxt/src/app/diagnostics/data.ts
why: (p: { key: string, fn: string, warnings: string }) =>
  `Incompatible options detected for "${p.key}" in \`${p.fn}\`:\n${p.warnings}`,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nuxt/src/app/composables/asyncData.ts` around lines 400 - 420, The
NUXT_E3004 diagnostic currently omits the async-data function name, making
duplicate-options warnings harder to trace. In asyncData.ts, pass the dev-only
_functionName through to dataDiagnostics.NUXT_E3004 alongside key and warnings,
and update the NUXT_E3004 template in diagnostics/data.ts to include that fn
field in the emitted message.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/kit/src/diagnostics/_shared.ts`:
- Around line 11-12: The docs URL in docsBase is being exposed as a raw
interpolated template literal, which Lychee interprets as a literal URL and
trips over the placeholder. Refactor docsBase in _shared.ts to construct the
path from a separate base constant or with new URL() plus string concatenation,
so the source no longer contains the full interpolated URL verbatim while still
returning the same final docs link.
- Around line 16-21: The exported `reporters` constant in `_shared.ts` relies on
an inferred tuple type, which can interfere with declaration generation in
`tsdown` with `dts: { oxc: true }`. Add an explicit type annotation for
`reporters` so the exported shape is stable and declaration emit can succeed.
Use the existing `reporters` export and the
`createConsoleReporter`/`ansiFormatter` expression as the location to update,
without changing runtime behavior.

In `@packages/kit/src/diagnostics/components.ts`:
- Line 5: Add an explicit type annotation to the exported diagnostics object so
declaration emit under isolatedDeclarations does not rely on inference. Update
componentDiagnostics to declare its type at the export, and apply the same fix
to the other defineDiagnostics(...) exports in packages/kit/src/diagnostics/*.ts
so all exported diagnostics objects have explicit types.

In `@packages/kit/src/diagnostics/config.ts`:
- Line 5: The `configDiagnostics` export in `defineDiagnostics` is missing an
explicit exported type, which triggers declaration-generation issues under
isolated declarations. Update the `configDiagnostics` definition to use a named,
exported type annotation so TypeScript can emit declarations cleanly for
`@nuxt/kit`, and keep the symbol name `configDiagnostics` unchanged so existing
imports continue to work.

In `@packages/kit/src/diagnostics/head.ts`:
- Line 5: The exported diagnostics catalogue in headDiagnostics needs an
explicit declared type so declaration emit can succeed. Update the export at
headDiagnostics to include a concrete type annotation using the appropriate
diagnostics catalogue type from defineDiagnostics, keeping the existing
initialization logic intact. Use the headDiagnostics symbol and the
defineDiagnostics call to locate the export and add the annotation without
changing its runtime behavior.

In `@packages/kit/src/module/install.ts`:
- Around line 347-351: The module-missing check in install.ts is using a broad
includes() match, which can incorrectly treat sibling packages with the same
prefix as the requested module and raise NUXT_B8018 for the wrong failure.
Update the logic around MissingModuleMatcher and kitDiagnostics.NUXT_B8018 to
compare the extracted module against nuxtModule exactly, or only accept direct
subpath variants of the requested specifier. Keep the existing subdependency
guard, but make the requested-module detection precise so only the intended
module name triggers this diagnostic.

In `@packages/nuxt/src/app/components/nuxt-island.ts`:
- Around line 239-241: The diagnostic detail in nuxt-island’s catch block is too
narrow because it reads e.message from an any, which becomes undefined for
string or plain-object throwables. Update the error normalization in the
NUXT_E4012 path so the detail is derived from the thrown value itself (like the
previous toString() behavior) before calling renderDiagnostics.NUXT_E4012,
keeping the existing status/name/cause handling intact.

In `@packages/nuxt/src/app/composables/once.ts`:
- Around line 25-29: The callback validation in callOnce should remain
unconditional, because fn is required and allowing undefined makes
callOnce('key') fail later with a raw runtime error instead of NUXT_E7008.
Update the guard in once.ts so the NUXT_E7008 check still rejects any
non-function value, including undefined, before execution reaches the later call
site in callOnce.

In `@packages/nuxt/src/app/composables/router.ts`:
- Around line 182-186: The `navigateTo` open-path still throws a plain `Error`
before reaching the new diagnostics, so the script-protocol case is not using
the stable contract. Update the `navigateTo` logic in `router.ts` so the earlier
`options.open` guard uses the same `NUXT_E2002` diagnostic as the `toPath` URL
check, and make sure the check reports the resolved protocol consistently for
both paths.

In `@packages/nuxt/src/app/diagnostics/_shared.ts`:
- Around line 17-18: The docsBase helper is embedding an unresolved template
literal URL, which the link-checker treats as a real link. Update docsBase to
build the docs URL from a base constant or via new URL() instead of
interpolating the path directly, and keep the code.replace('NUXT_',
'').toLowerCase() logic intact while moving the URL construction into a
non-literal form.

In `@packages/nuxt/src/app/diagnostics/navigation.ts`:
- Around line 15-18: The `NUXT_E2002` diagnostic fix text is too narrow because
`isScriptProtocol(protocol)` only blocks script-like schemes, not all non-http
URLs. Update the `fix` message in the `NUXT_E2002` entry to explain that
`javascript:`-style protocols are blocked for security, while safe schemes like
`mailto:` and `tel:` remain valid, and direct users to use a safe URL/protocol
appropriate for the link target.

In `@packages/nuxt/src/app/diagnostics/render.ts`:
- Around line 66-68: Update the NUXT_E4012 guidance in the diagnostics mapping
so it matches the actual failure path in nuxt-island.ts: the parse error comes
from r.json(), not HTML parsing. Keep the why message in render.ts as-is, but
change the fix text to instruct users to verify the island endpoint returns
valid JSON/island payload, and mention it may have returned an HTML error page
instead.

In `@packages/nuxt/src/app/diagnostics/state.ts`:
- Around line 36-39: The NUXT_E7006 diagnostic currently exposes sensitive
cookie values in its why message; update the diagnostic in state.ts so the
NUXT_E7006 entry only mentions the cookie name or uses redacted placeholders
instead of p.previous and p.next. Keep the fix in the NUXT_E7006 catalog entry
and adjust the why function signature or formatting in that diagnostic so SSR
logs never contain raw cookie contents.

In `@packages/nuxt/src/components/scan.ts`:
- Around line 101-102: The `scan.ts` diagnostics for `NUXT_B3009` and
`NUXT_B3011` are still using raw filesystem paths, unlike the other component
warnings in this file. Update the `componentDiagnostics.NUXT_B3009` and
`componentDiagnostics.NUXT_B3011` calls in `scanComponents` to pass the path
through `resolveToAlias(...)` first, matching the existing usage near the other
diagnostics so `filePath` is consistent across machines.

In `@packages/nuxt/src/core/app.ts`:
- Around line 68-70: The `compileTemplate()` rejection handler in `app.ts` is
wrapping every failure in `NUXT_B1001`, which overrides the more specific
`NUXT_B1002`/`NUXT_B1003` diagnostics. Update the
`compileTemplate(...).catch(...)` logic so `NUXT_B1001` is only emitted for
unexpected exceptions, and let already-coded template failures pass through with
their original diagnostic. Apply the same change in the other `compileTemplate`
call site referenced by the comment.

In `@packages/nuxt/src/pages/runtime/plugins/router.ts`:
- Around line 250-252: The NUXT_E2004 navigation diagnostic in the router
middleware path is missing the registered named middleware context, so the dev
error no longer shows which middleware names are available. Update the call site
in the router plugin to pass the current named middleware set into
navigationDiagnostics.NUXT_E2004, or preserve the existing dev-only suffix that
includes that list, using the surrounding middleware handling logic and the
NUXT_E2004 symbol to locate the fix.

In `@packages/vite/src/plugins/optimize-deps-hint.ts`:
- Around line 126-128: The stale-deps hint branch in optimize-deps-hint should
preserve the stale dependency names instead of emitting an empty NUXT_B7002
payload. Update the hasStale path in the logic around formatStaleDepsHint so it
still passes the userStale/moduleStale information (or equivalent stale dep
names) into bundlerDiagnostics.NUXT_B7002, keeping the warning actionable when
no new deps are discovered.

---

Outside diff comments:
In `@packages/nuxt/src/components/plugins/lazy-hydration-transform.ts`:
- Around line 95-105: Normalize the file path used by NUXT_B3005 in
lazy-hydration-transform so it matches the aliased path format already used for
NUXT_B3006. Update the componentDiagnostics.NUXT_B3005 call to pass
resolveToAlias(id, nuxt) (or an equivalent shared normalized value) instead of
the raw id, so both diagnostics report consistent, environment-independent file
references.

In `@packages/nuxt/src/pages/plugins/page-meta.ts`:
- Around line 103-112: Restore the hard failure path in page-meta handling: in
the empty-module branch inside the page transform logic, after
`pageDiagnostics.NUXT_B4001` is emitted, throw again instead of returning
`result()`. Update the `page-meta.ts` flow around `hasMacro`, `parseModuleId`,
and `pageDiagnostics.NUXT_B4001` so empty `?macro=true` modules still stop the
build rather than continuing with the fallback transform output.

---

Nitpick comments:
In `@packages/nuxt/src/app/composables/asyncData.ts`:
- Around line 400-420: The NUXT_E3004 diagnostic currently omits the async-data
function name, making duplicate-options warnings harder to trace. In
asyncData.ts, pass the dev-only _functionName through to
dataDiagnostics.NUXT_E3004 alongside key and warnings, and update the NUXT_E3004
template in diagnostics/data.ts to include that fn field in the emitted message.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 60ca06a3-6ab8-4270-9805-477a5ff74a17

📥 Commits

Reviewing files that changed from the base of the PR and between 369a6c6 and 89a4900.

⛔ Files ignored due to path filters (3)
  • packages/kit/package.json is excluded by !**/package.json
  • packages/nuxt/package.json is excluded by !**/package.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (122)
  • docs/errors/.navigation.yml
  • docs/errors/b5001.md
  • docs/errors/b5003.md
  • docs/errors/b5004.md
  • docs/errors/e1001.md
  • docs/errors/e1006.md
  • docs/errors/e1007.md
  • docs/errors/e2001.md
  • docs/errors/e2002.md
  • docs/errors/e2003.md
  • docs/errors/e2004.md
  • docs/errors/e2005.md
  • docs/errors/e2007.md
  • docs/errors/e6001.md
  • eslint.config.mjs
  • packages/kit/src/compatibility.ts
  • packages/kit/src/components.ts
  • packages/kit/src/context.ts
  • packages/kit/src/dependency.ts
  • packages/kit/src/diagnostics/_shared.ts
  • packages/kit/src/diagnostics/build.ts
  • packages/kit/src/diagnostics/bundler.ts
  • packages/kit/src/diagnostics/components.ts
  • packages/kit/src/diagnostics/config.ts
  • packages/kit/src/diagnostics/head.ts
  • packages/kit/src/diagnostics/kit-api.ts
  • packages/kit/src/diagnostics/pages.ts
  • packages/kit/src/diagnostics/plugins.ts
  • packages/kit/src/index.ts
  • packages/kit/src/layout.ts
  • packages/kit/src/loader/nuxt.ts
  • packages/kit/src/module/define.ts
  • packages/kit/src/module/install.ts
  • packages/kit/src/nitro.ts
  • packages/kit/src/pages.ts
  • packages/kit/src/plugin.ts
  • packages/kit/src/resolve.ts
  • packages/kit/src/template.ts
  • packages/kit/test/plugin.test.ts
  • packages/nitro-server/src/index.ts
  • packages/nuxt/src/app/compat/interval.ts
  • packages/nuxt/src/app/components/client-fallback.server.ts
  • packages/nuxt/src/app/components/island-renderer.ts
  • packages/nuxt/src/app/components/nuxt-island.ts
  • packages/nuxt/src/app/components/nuxt-layout.ts
  • packages/nuxt/src/app/components/nuxt-link.ts
  • packages/nuxt/src/app/components/route-provider.ts
  • packages/nuxt/src/app/components/test-component-wrapper.ts
  • packages/nuxt/src/app/components/utils.ts
  • packages/nuxt/src/app/composables/asyncData.ts
  • packages/nuxt/src/app/composables/component.ts
  • packages/nuxt/src/app/composables/cookie.ts
  • packages/nuxt/src/app/composables/fetch.ts
  • packages/nuxt/src/app/composables/manifest.ts
  • packages/nuxt/src/app/composables/once.ts
  • packages/nuxt/src/app/composables/payload.ts
  • packages/nuxt/src/app/composables/preload.ts
  • packages/nuxt/src/app/composables/router.ts
  • packages/nuxt/src/app/composables/ssr.ts
  • packages/nuxt/src/app/composables/state.ts
  • packages/nuxt/src/app/diagnostics/_shared.ts
  • packages/nuxt/src/app/diagnostics/core.ts
  • packages/nuxt/src/app/diagnostics/data.ts
  • packages/nuxt/src/app/diagnostics/head.ts
  • packages/nuxt/src/app/diagnostics/manifest.ts
  • packages/nuxt/src/app/diagnostics/navigation.ts
  • packages/nuxt/src/app/diagnostics/render.ts
  • packages/nuxt/src/app/diagnostics/state.ts
  • packages/nuxt/src/app/entry.ts
  • packages/nuxt/src/app/nuxt.ts
  • packages/nuxt/src/app/plugins/check-if-layout-used.ts
  • packages/nuxt/src/app/plugins/payload.client.ts
  • packages/nuxt/src/app/plugins/router.ts
  • packages/nuxt/src/compiler/module.ts
  • packages/nuxt/src/compiler/plugins/keyed-function-factories.ts
  • packages/nuxt/src/compiler/plugins/keyed-functions.ts
  • packages/nuxt/src/compiler/runtime/index.ts
  • packages/nuxt/src/components/module.ts
  • packages/nuxt/src/components/plugins/islands-transform.ts
  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts
  • packages/nuxt/src/components/plugins/loader.ts
  • packages/nuxt/src/components/plugins/transform.ts
  • packages/nuxt/src/components/scan.ts
  • packages/nuxt/src/core/app.ts
  • packages/nuxt/src/core/builder.ts
  • packages/nuxt/src/core/cache.ts
  • packages/nuxt/src/core/external-config-files.ts
  • packages/nuxt/src/core/features.ts
  • packages/nuxt/src/core/nuxt.ts
  • packages/nuxt/src/core/plugins/plugin-metadata.ts
  • packages/nuxt/src/core/schema.ts
  • packages/nuxt/src/core/server.ts
  • packages/nuxt/src/head/plugins/unhead-imports.ts
  • packages/nuxt/src/head/runtime/components.ts
  • packages/nuxt/src/head/runtime/composables.ts
  • packages/nuxt/src/imports/module.ts
  • packages/nuxt/src/pages/module.ts
  • packages/nuxt/src/pages/plugins/page-meta.ts
  • packages/nuxt/src/pages/runtime/composables.ts
  • packages/nuxt/src/pages/runtime/page-placeholder.ts
  • packages/nuxt/src/pages/runtime/plugins/check-if-page-unused.ts
  • packages/nuxt/src/pages/runtime/plugins/router.ts
  • packages/nuxt/src/pages/utils.ts
  • packages/nuxt/test/compiler.test.ts
  • packages/nuxt/test/diagnostics-catalog.test.ts
  • packages/nuxt/test/island-transform.test.ts
  • packages/nuxt/test/keyed-functions.test.ts
  • packages/nuxt/test/page-metadata.test.ts
  • packages/nuxt/test/plugin-metadata.test.ts
  • packages/vite/src/css.ts
  • packages/vite/src/plugins/analyze.ts
  • packages/vite/src/plugins/decorators.ts
  • packages/vite/src/plugins/optimize-deps-hint.ts
  • packages/vite/src/plugins/vite-node.ts
  • packages/vite/src/plugins/vue-jsx.ts
  • packages/vite/src/utils/config.ts
  • packages/vite/test/optimize-deps-hint.test.ts
  • packages/webpack/src/plugins/vue/server.ts
  • packages/webpack/src/plugins/vue/util.ts
  • packages/webpack/src/utils/config.ts
  • packages/webpack/src/utils/postcss.ts
  • packages/webpack/src/webpack.ts

Comment thread packages/kit/src/diagnostics/_shared.ts
Comment thread packages/kit/src/diagnostics/_shared.ts
Comment thread packages/kit/src/diagnostics/components.ts
Comment thread packages/kit/src/diagnostics/config.ts
Comment thread packages/kit/src/diagnostics/head.ts
Comment thread packages/nuxt/src/app/diagnostics/state.ts
Comment on lines 101 to +102
if (LAZY_COMPONENT_NAME_REGEX.test(pascalName)) {
logger.warn(`The component \`${pascalName}\` (in \`${filePath}\`) is using the reserved "Lazy" prefix used for dynamic imports, which may cause it to break at runtime.`)
componentDiagnostics.NUXT_B3009({ component: pascalName, filePath })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Resolve component paths before emitting NUXT_B3009 and NUXT_B3011.

Line 102 and Line 174 still pass raw filesystem paths, but Line 50 and Line 142 in the same file already use resolveToAlias(...). Keeping these two diagnostics raw makes the new output inconsistent across machines and less useful for users copying paths back into config.

Suggested fix
       if (LAZY_COMPONENT_NAME_REGEX.test(pascalName)) {
-        componentDiagnostics.NUXT_B3009({ component: pascalName, filePath })
+        componentDiagnostics.NUXT_B3009({ component: pascalName, filePath: resolveToAlias(filePath) })
       }
@@
 function warnAboutDuplicateComponent (componentName: string, filePath: string, duplicatePath: string) {
-  componentDiagnostics.NUXT_B3011({ component: componentName, filePath, duplicatePath })
+  componentDiagnostics.NUXT_B3011({
+    component: componentName,
+    filePath: resolveToAlias(filePath),
+    duplicatePath: resolveToAlias(duplicatePath),
+  })
 }

Also applies to: 173-174

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nuxt/src/components/scan.ts` around lines 101 - 102, The `scan.ts`
diagnostics for `NUXT_B3009` and `NUXT_B3011` are still using raw filesystem
paths, unlike the other component warnings in this file. Update the
`componentDiagnostics.NUXT_B3009` and `componentDiagnostics.NUXT_B3011` calls in
`scanComponents` to pass the path through `resolveToAlias(...)` first, matching
the existing usage near the other diagnostics so `filePath` is consistent across
machines.

Comment thread packages/nuxt/src/core/app.ts
Comment thread packages/nuxt/src/pages/runtime/plugins/router.ts Outdated
Comment thread packages/vite/src/plugins/optimize-deps-hint.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/nuxt/src/app/composables/asyncData.ts`:
- Around line 359-362: The validation guards in asyncData should preserve the
existing TypeError contract instead of switching to Error-based diagnostics.
Update the checks in useAsyncData so the _key and _handler failures still throw
TypeError while keeping the same diagnostic messages, and make sure the existing
NUXT_E3008 and NUXT_E3009 paths continue to satisfy instanceof TypeError
expectations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c95362d7-11d5-4ae3-9a39-fc90e946b597

📥 Commits

Reviewing files that changed from the base of the PR and between 89a4900 and 775f543.

📒 Files selected for processing (6)
  • packages/nuxt/src/app/composables/asyncData.ts
  • packages/nuxt/src/app/composables/ssr.ts
  • packages/nuxt/src/app/diagnostics/core.ts
  • packages/nuxt/src/app/diagnostics/data.ts
  • packages/nuxt/src/app/diagnostics/manifest.ts
  • packages/nuxt/src/app/diagnostics/state.ts
💤 Files with no reviewable changes (2)
  • packages/nuxt/src/app/diagnostics/state.ts
  • packages/nuxt/src/app/diagnostics/manifest.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/nuxt/src/app/diagnostics/core.ts

Comment thread packages/nuxt/src/app/composables/asyncData.ts Outdated
Comment thread test/bundle.test.ts Outdated
@pkg-pr-new

pkg-pr-new Bot commented Jul 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@35429

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@35429

nuxt

npm i https://pkg.pr.new/nuxt@35429

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@35429

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@35429

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@35429

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@35429

commit: 0456be1

@codspeed-hq

codspeed-hq Bot commented Jul 1, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 19 untouched benchmarks
⏩ 3 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
initial production build in the minimal test fixture 1.8 s 2 s -13.88%
loadNuxtConfig in the basic test fixture (types) 22 ms 16.9 ms +30.26%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/nostics-errors (0456be1) with main (60ce78b)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Comment thread packages/nitro-server/src/index.ts Fixed
Comment thread lychee.toml Outdated
Comment thread test/fixtures/minimal-pages/nuxt.config.ts
Comment thread test/bundle.test.ts Outdated

const serverStats = await analyzeSizes(['**/*.mjs', '!_libs'], serverDir, rootDir)
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"69.0k"`)
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"80.5k"`)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems too big of a bump 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it didn’t change 😮
Was this introduced in my PR or is it during a rebase?

@danielroe danielroe Jul 13, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this was introduced in this PR. I backported the test: false change into main, to confirm.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I Will have to check. I light have forgotten some defineProdDiagnostics

@posva posva Jul 14, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and it's weird it goes up so much. Even when using the prod diagnostics, it goes to 75k. If this is important, I can enforce the defineProdDiagnostics() which removes all of the error messages and reporters (no logs) to have only the error code appear (useful for thrown errors)

@posva posva Jul 14, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, the extra 5kb are the unminified + jsdocs that appear in entry.mjs:

@posva-Ghostty‒ tacobook ❐ 0 ● 11 bat-2026-07-14-16 30 52@2x

The version of the screenshot is by using the production branch when bundling but I don't know if we want to go that way

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting a bit further with this, especially for the client side bundle. Some increases are intentional, some are because we include more information in the errors like here

@posva-Microsoft Edge‒feat error code system by posv…ull Request #35429 · nuxtnuxt-2026-07-15-13 55 00@2x

I think we can refactor the method: 'error' to apply to most of these

WDYT @danielroe ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are jsdocs appearing in the prod bundle? 🤔 this must be a bug on our end, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the server bundle is not minified. It feels intentional but can probably be configured

Comment thread packages/nuxt/src/app/diagnostics/head.ts Outdated
@danielroe

Copy link
Copy Markdown
Member

summarising my recent pushes:

  • every code that can throw in prod now has a docs page (codes without pages were 404ing in prod)
  • restored prod logging where we previously logged - things like client app init errors (E1005) had gone silent in prod builds. they now log the error code + cause
  • island-renderer was reusing E4012 with status: 0 for captured render errors, which would have read as "failed to parse island response (HTTP 0)" - gave it its own code
  • wired up or dropped the unused codes (B2001/B2002 are now used for the plugin metadata throws), consolidated a few duplicates, and fixed some messages (E4007 was suggesting pages: false to disable layouts ...)
  • restored the (used at file:line:col) caller info on the async data warnings via the nostics sources param

let me know if I've misunderstood any of that or we should reconsider

... and thank you so much for all your work on this - it's looking amazing! 🚀

@posva

posva commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

This sounds great! I'm glad you took a look. I'm going to give it another look

Comment thread packages/kit/src/diagnostics/_shared.ts Outdated
@danielroe
danielroe force-pushed the feat/nostics-errors branch from f07374b to 54b933e Compare July 15, 2026 15:02
Comment thread docs/errors/e7009.md
@@ -0,0 +1,18 @@
---

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end, are we agreeing on always having a page? I think adding it to contributing or to an agents.md would ease the maintainance

@danielroe danielroe Jul 16, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added more pages just because (IIUC) prod errors always link to a page even if you pass docs: false (because this is tree-shaken out)....

I'm happy to ship this PR without all pages, but I think it makes sense eventually to have pages for every one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry I missed that you already said it in the review! This PR is huge so I'm losing myself in it sometimes.

I think you took the better direction

Comment thread packages/nuxt/src/app/components/nuxt-link.ts Outdated
Comment thread packages/nuxt/src/app/composables/preload.ts Outdated
})

expect(() => factory('a', 1)).toThrowErrorMatchingInlineSnapshot(`[Error: [nuxt] \`createUseFetch\` is a compiler macro and cannot be called at runtime.]`)
expect(() => factory('a', 1)).toThrowErrorMatchingInlineSnapshot(`[NUXT_E1007: NUXT_E1007]`)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe worth flagging:

  • do we want [Error: NUXT_E1007]? (that would be a nostics change)
  • should we just add a simple console.error log in prod and remove the manual if (!importe.meta.dev) console.error(diangostics.NUXT_E1007().name) ?

@danielroe danielroe Jul 16, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preserving the source of truth in diagnostics seems valuable, rather than inlining a console.error

[NUXT_E1007: NUXT_E1007] seems strange - I think just [NUXT_E1007] would be better

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on the strangeness of the [...: ...]

Then, I can add a custom reporter for this in prod only

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in other places but here, it's the production throw, so no real control over how it's displayed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does nostics show it like this?

Comment thread packages/nuxt/test/keyed-functions.test.ts Outdated
Comment thread test/bundle.test.ts Outdated
Add the nostics dependency and a build-time diagnostics catalog
(packages/kit/src/diagnostics.ts). Migrate the first call site
(addPlugin src validation) to throw diagnostics.NUXT_B2011 and add the
b2011 error reference doc plus the errors/ navigation stub.
Merged via the queue into main with commit 5d67c9e Jul 18, 2026
33 checks passed
@danielroe
danielroe deleted the feat/nostics-errors branch July 18, 2026 10:02
This was referenced Jul 18, 2026
danielroe added a commit that referenced this pull request Jul 18, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Roe <daniel@roe.dev>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@github-actions github-actions Bot mentioned this pull request Jul 17, 2026
@github-actions github-actions Bot mentioned this pull request Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.x ✨ enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.