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): stop loading indicator on vue errors #20738
fix(nuxt): stop loading indicator on vue errors #20738
Conversation
Β Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
if (process.client && !nuxtApp.isHydrating) { | ||
emit('error', err) | ||
nuxtApp.hooks.callHook('vue:error', err, target, info) |
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.
My main question about calling it here is that we explicitly say this will only be called when errors propagate up:
In addition, Nuxt provides a `vue:error` hook that will be called if any errors propagate up to the top level. |
I think the concept here is that the error boundary establishes a different kind of error handling. But I'm open to discussion.
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.
Yes, it makes sense.
The problem is that when error occurs inside an error boundary neither page:finish nor vue:error are called, so not only loading indicator remains active, but view transitions are not finished or aborted either.
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.
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.
I think we could use page:finish
there π
The page:
hooks are really about suspense rather than changing route. (They won't run if a page does not have an async setup or async dependencies, for example.)
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.
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.
So, to recap
// /nuxt/src/pages/runtime/page.ts
setup (props, { attrs }) {
const nuxtApp = useNuxtApp()
const done = nuxtApp.deferHydration()
onErrorCaptured(() => {
nuxtApp.callHook('page:finish').finally(done)
})
It works, but for sync components page:finish gets called twice, because onResolve
from Suspense
also gets called
π Linked issue
#15788
β Type of change
π Description
NuxtErrorBoundary
to signal that there was an errorπ Checklist