fix: ensure consistent error data serialization in production#29
fix: ensure consistent error data serialization in production#29
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thank you for following the naming conventions! 🙏 |
createError data lost in production
commit: |
|
@NicolaSpadari, can you try to see if this version fixes the problem |
There was a problem hiding this comment.
Pull request overview
Improves EvlogError serialization/shape to preserve structured error data across Nitro/H3 versions (v2/v1 vs v3/v2), addressing production cases where custom error data was being dropped.
Changes:
- Add Nitro v3+/H3 v2+ compatible fields (
status,statusText) while keeping legacy (statusCode,statusMessage) as deprecated. - Move structured error context (
why/fix/link) into a dedicateddataobject for consistent serialization. - Update
parseErrorand tests to recognize both Nitro/H3 generations’ status/message fields.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/evlog/src/error.ts | Extends EvlogError with status/statusText + legacy fields and serializes structured context under data. |
| packages/evlog/src/runtime/utils/parseError.ts | Parses both Nitro v3+/v2 error response shapes for status and message fields. |
| packages/evlog/test/error.test.ts | Updates/extends tests to cover the new status fields and the new JSON shape (data). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thank you for the quick check. Unfortunately, still seems to occur, and the "why" key gets lost after build. I created a reproduction here https://github.com/NicolaSpadari/evlog-data-reproduction Just try to run it as dev, click the button, see the network response. "message" still comes through, "why" doesn't |
|
@NicolaSpadari And this time? with https://pkg.pr.new/evlog@116c96f |
|
Yes, looks like it's working! |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
createError data lost in productionThere was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| url, | ||
| statusCode: status, | ||
| statusMessage: message, | ||
| message, | ||
| error: true, |
There was a problem hiding this comment.
The serialized response body only includes legacy statusCode/statusMessage. Since this PR introduces status/statusText for newer Nitro/H3/Nuxt versions, consider including status and statusText alongside the legacy fields in the JSON payload to make the on-the-wire format consistent and forward-compatible (without breaking existing consumers).
- Cache `this.data` in toJSON() to avoid calling getter twice - Derive message from statusText/statusMessage/message for cross-version compat - Add status/statusText fields to JSON response for Nuxt 4+ compatibility Co-authored-by: Cursor <cursoragent@cursor.com>
Resolves #24
This pull request updates the
EvlogErrorclass and related utilities to improve compatibility across different versions of Nitro/H3, enhance structured error data, and modernize the API.The main changes introduce new status and message properties, deprecate legacy ones, and ensure consistent error serialization and parsing.