Skip to content

feat(dev): better errors inspired by nitro#1383

Merged
danielroe merged 1 commit into
mainfrom
feat/errors
Jul 25, 2026
Merged

feat(dev): better errors inspired by nitro#1383
danielroe merged 1 commit into
mainfrom
feat/errors

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

this borrows some nice work from the nitro dev server to improve error handling display

SCR-20260725-bevp

@codspeed-hq

codspeed-hq Bot commented Jul 25, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing feat/errors (11955a0) with main (4ac2954)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (cff4db2) during the generation of this report, so 4ac2954 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@pkg-pr-new

pkg-pr-new Bot commented Jul 25, 2026

Copy link
Copy Markdown
  • nuxt-cli-playground

    npm i https://pkg.pr.new/create-nuxt@1383
    
    npm i https://pkg.pr.new/nuxi@1383
    
    npm i https://pkg.pr.new/@nuxt/cli@1383
    

commit: 11955a0

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3563412f-47b2-4564-9215-6381253669da

📥 Commits

Reviewing files that changed from the base of the PR and between 7ab01b6 and 11955a0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • knip.json
  • packages/nuxi/package.json
  • packages/nuxi/src/dev/error.ts
  • packages/nuxi/src/dev/utils.ts
  • packages/nuxt-cli/package.json
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/nuxi/src/dev/utils.ts
  • packages/nuxi/package.json
  • knip.json
  • packages/nuxi/src/dev/error.ts

📝 Walkthrough

Walkthrough

The change adds source-map and youch-core dependencies, implements source-mapped stack processing for HTML, JSON, and ANSI error output, and recursively processes error causes. Development loading responses now negotiate HTML or JSON, include cache and refresh headers, and format startup or restart failures with ANSI-rendered stacks.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main dev error-handling improvement.
Description check ✅ Passed The description is clearly related to the PR and matches the error display improvements from Nitro.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/nuxi/src/dev/error.ts (1)

22-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated content-negotiation logic between renderError and #renderLoadingScreen. Both independently re-implement the Accept: text/html check and a JSON error-body shape; extracting a shared helper avoids the two drifting apart as headers/fields evolve.

  • packages/nuxi/src/dev/error.ts#L22-L45: export a wantsJSON(req) helper (or similar) from error.ts and reuse it here instead of inlining !req.headers.accept?.includes('text/html').
  • packages/nuxi/src/dev/utils.ts#L199-L231: import and reuse the same helper for the 503 loading-screen negotiation instead of re-checking the Accept header locally.
🤖 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/nuxi/src/dev/error.ts` around lines 22 - 45, Extract the shared
Accept-header negotiation into an exported wantsJSON helper in renderError’s
error.ts flow, replacing its inline check. In packages/nuxi/src/dev/error.ts
lines 22-45, define and use the helper; in packages/nuxi/src/dev/utils.ts lines
199-231, import and reuse it for `#renderLoadingScreen`’s 503 response, preserving
the existing JSON negotiation and response shapes.
🤖 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/nuxi/src/dev/error.ts`:
- Around line 65-99: Update sourceLoader’s app-frame source-map handling to use
SourceMapConsumer.with, ensuring each consumer is released after mapping.
Isolate originalPositionFor failures for malformed maps with per-frame try/catch
so one mapping error does not reject ErrorParser.parse; retain frame processing
and file loading for other frames.

---

Nitpick comments:
In `@packages/nuxi/src/dev/error.ts`:
- Around line 22-45: Extract the shared Accept-header negotiation into an
exported wantsJSON helper in renderError’s error.ts flow, replacing its inline
check. In packages/nuxi/src/dev/error.ts lines 22-45, define and use the helper;
in packages/nuxi/src/dev/utils.ts lines 199-231, import and reuse it for
`#renderLoadingScreen`’s 503 response, preserving the existing JSON negotiation
and response shapes.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 42708d1c-5eb0-4041-a265-9f4419aeaa63

📥 Commits

Reviewing files that changed from the base of the PR and between cff4db2 and 7ab01b6.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • knip.json
  • packages/nuxi/package.json
  • packages/nuxi/src/dev/error.ts
  • packages/nuxi/src/dev/utils.ts
  • packages/nuxt-cli/package.json

Comment thread packages/nuxi/src/dev/error.ts
@danielroe
danielroe merged commit 7ec738e into main Jul 25, 2026
19 checks passed
@danielroe
danielroe deleted the feat/errors branch July 25, 2026 07:21
@github-actions github-actions Bot mentioned this pull request Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant