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(nuxt): handle errors when booting app with app:error
#24376
Conversation
Run & review this pull request in StackBlitz Codeflow. |
packages/nuxt/src/app/entry.ts
Outdated
@@ -76,6 +85,8 @@ if (import.meta.client) { | |||
nuxt.payload.error = (nuxt.payload.error || err) as any | |||
} | |||
|
|||
vueApp.config.errorHandler = prevVueErrorHandler |
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.
Reset back to undefined. Or should we actually always provide the handler with a better experience?
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.
Interesting question. I'd be up for always providing an error handler.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #24376 +/- ##
=======================================
Coverage ? 58.76%
=======================================
Files ? 5
Lines ? 861
Branches ? 46
=======================================
Hits ? 506
Misses ? 355
Partials ? 0 ☔ View full report in Codecov by Sentry. |
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.
Does this also need to be included in server-side fork?
|
app:error
Without a custom
errorHandler
, Vue will throw an error and crash itself in dev, causing Vue's singleton context has a broken state. In that case, it will cause off-root apps (anothercreateApp
) to fail to work. Nuxt DevTools creates a separate app to mount itself, and this PR fixes that DevTools does not work on the error page.This probably also improves the error capture in Production? As in production, unhandled error are not thrown, make the
try catch
inentry.ts
not been able to capture them.