-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Nuxt error() does not stop execution of previous component #4649
Comments
This would be pretty sweet, but pretty hard to actually pull off especially in all the places you can call error() .. like asyncData, fetch, created (via this.$nuxt.error) etc.. |
However, calling error even within the places you summed up, would probably promote proper error handling flow. As currently everything below the error can cause unneeded side effects. I've updated my example with a Maybe i'm biased by other languages (as javascript isn't my primary), but having a middleware be able to call error for instance, while components still are able to make state changes or worse, feels like a smell to me. |
If you were just showing a 'uh oh something sploded' message and sending a raw response to the browser, then I think that may be easier, but since Nuxt lets you show a pretty error message where other stuff really is rendered and code just doesn't early-out I think this is challenging. I'm just guessing.. In the end, I want the same thing you do, as I too have to code against edge cases. (Api returned 404, then return null to vuex, then in comps handle if computed prop is null within asyncData/fetch/router guards etc.. Having error messages being a 'full stop' would make thinks much easier. |
Thanks for your contribution to Nuxt.js!
Issues that are labeled as |
Thanks for your contribution to Nuxt.js!
Issues that are labeled as |
I'm curious how the reproduction looked like for this because I've made some fix that might be relevant - #20719 Unfortunately the original repo is no longer present. |
@rchl Yeah after years of no response I deleted it, sorry. From what I can remember:
Hope this helps in any way. Also keep in mind that this was quite an early version of nuxt 2. Your proposed implementation does looks like a way to fix the issue however. |
And where was $http used from? Async data? created hook? Middleware? |
Version
v2.3.4
Reproduction link
https://github.com/jovanmaric/nuxt-axios-error
Steps to reproduce
The reproduction link contains a generated app with the latest Nuxt and the following setup:
To reproduce you should run
yarn dev
and open the console on chrome.What is expected ?
That the error component is injected instead of the original component, removing all the semantics of the original component.
What is actually happening?
Uncaught (in promise) TypeError: Cannot read property '_t' of null
while no code of the original component should be ran.Additional comments?
The above error does not only apply to the
created()
method. Leading me to think that the re-render is retriggered on server side, while this shouldn't be when the error component injects itself instead of the original component.The text was updated successfully, but these errors were encountered: