-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix(nitro): check prettyResponse.body type before error overlay #33977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(nitro): check prettyResponse.body type before error overlay #33977
Conversation
|
|
|
this has already been solved. the issue was not prettyResponse not being a string - the issue was html not being one which is why we added a check for it. |
WalkthroughA type guard was introduced in the error handler for the development error overlay path to validate that Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 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 |
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #33977 will not alter performanceComparing Summary
|
danielroe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!

🔗 Linked issue
Resolves #33748
📋 Problem Statement
Users are seeing this error in dev mode, commonly triggered by service worker requests (
/sw.js,/dev-sw.js):🔍 Root Cause
In Nitro's dev error handler, the logic for determining JSON vs HTML response is:
When
defaultHandler(error, event, { json: false })is called,opts.jsonis falsy so it still checks theAcceptheader. Requests like/sw.jsdon't includeAccept: text/html, souseJSONends uptrueand returns an object instead of HTML string.This causes
generateErrorOverlayHTMLto fail when calling.replace()on a non-string.✅ Solution
Add a type check before passing
prettyResponse.bodytogenerateErrorOverlayHTML:Falls back to regular error page without overlay when body is not a string.