Fix HTTPError.body forwarding in error handlers#3977
Draft
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Updated dev.ts and prod.ts to spread error.body properties at top level - Added test case for HTTPError.body in test fixture - Tests passing for both dev and prod error handlers Co-authored-by: pi0 <5158436+pi0@users.noreply.github.com>
- Added fallback to empty object for error.body to prevent runtime errors - Ensures safe spreading even when error.body is null or undefined Co-authored-by: pi0 <5158436+pi0@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Nitro v3 not forwarding H3 HTTPError.body to client
Fix HTTPError.body forwarding in error handlers
Jan 25, 2026
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nitro v3's error handlers were not forwarding H3 HTTPError
bodyproperties to clients. Thebodyfield should spread properties at the top level of error responses, per H3's error handling contract.Changes
src/runtime/internal/error/dev.ts: Spreaderror.bodyat top level of JSON responsesrc/runtime/internal/error/prod.ts: Spreaderror.bodyonly for non-sensitive errors (respects existing security model)Example
Before:
{ "error": true, "status": 500, "message": "Custom error message", "data": { "instance": "local" } }After:
{ "error": true, "status": 500, "message": "Custom error message", "data": { "instance": "local" }, "code": "urn:nitro:error-code" }Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
workers.cloudflare.com/usr/local/bin/node /usr/local/bin/node --conditions node --conditions production --experimental-import-meta-resolve --require /home/REDACTED/work/nitro/nitro/node_modules/.pnpm/vitest@4.0.17_@edge-runtime+vm@5.0.0_@types+node@25.0.9_jiti@2.6.1_lightningcss@1.31.1_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/nitro/nitro/node_modules/.pnpm/vitest@4.0.17_@edge-runtime+vm@5.0.0_@types+node@25.0.9_jiti@2.6.1_lightningcss@1.31.1_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/workers/forks.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.