feat(dev): better errors inspired by nitro#1383
Conversation
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThe change adds Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/nuxi/src/dev/error.ts (1)
22-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicated content-negotiation logic between
renderErrorand#renderLoadingScreen. Both independently re-implement theAccept: text/htmlcheck 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 awantsJSON(req)helper (or similar) fromerror.tsand 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 theAcceptheader 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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
knip.jsonpackages/nuxi/package.jsonpackages/nuxi/src/dev/error.tspackages/nuxi/src/dev/utils.tspackages/nuxt-cli/package.json
🔗 Linked issue
📚 Description
this borrows some nice work from the nitro dev server to improve error handling display