Repository navigation
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