Skip to content
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

Exceptions thrown in errorHandler halt app #6714

Closed
dts opened this issue Sep 28, 2017 · 8 comments
Closed

Exceptions thrown in errorHandler halt app #6714

dts opened this issue Sep 28, 2017 · 8 comments

Comments

@dts
Copy link

dts commented Sep 28, 2017

Version

2.4.4

Reproduction link

https://jsfiddle.net/qok5vcnf/1/

Steps to reproduce

Add an errorHandler that throws an exception, and notice that the app halts badly.

What is expected?

Exceptions thrown from errorHandlers should use the console to print something, or fail silently.

What is actually happening?

The whole app rendering halts.


Was using the raven-js plugin for Vue, which triggers this behavior. I have filed an issue over there with my feedback (getsentry/sentry-javascript#1061), but I thought it might save some future developers time to not fail quite so catastrophically in this case.

@posva
Copy link
Member

posva commented Sep 28, 2017

Why don't you console.error the error instead of throwing it inside of the errorHandler?
What's the point of an error handler if you throw the error again?

@dts
Copy link
Author

dts commented Sep 29, 2017

That is the patch I submitted to Raven, they were doing a lot of logic in their errorHandler (to increase the value of the reported error - good stuff, actually!) without careful try/catches, not to mention some things that made me suspect they hadn't run their Vue plugin in production much. That being said, the failure mode was so silent, catastrophic, (and hard to debug!) that I figured a quick try/catch around the errorHandler might save some people in the future some headache.

@posva
Copy link
Member

posva commented Sep 29, 2017

But I think you shouldn't throw errors in the errorHandler, you should treat all of them but not generate new one or ignore them (throwing them)

@dts
Copy link
Author

dts commented Sep 29, 2017

I agree with you. However, if you don't do what you should, I think the app shouldn't crash, especially since it's so easy to prevent that error from becoming catastrophic.

@posva
Copy link
Member

posva commented Sep 29, 2017

But that's because throwing errors in js make apps crash...

@dts
Copy link
Author

dts commented Sep 30, 2017

Almost anywhere in a Vue app, throwing an error does not.

ztlevi pushed a commit to ztlevi/vue that referenced this issue Feb 14, 2018
@siegy22
Copy link

siegy22 commented Aug 9, 2018

@dts How do I actually throw an error in your vue app then? after the commit 2b5c83a, there's no way of doing that anymore.

Why would I need this? Because I'm testing my vue.js app in a google chrome using cypress and I want to let a test fail when there's an error. But with the change, this is not possible anymore. So how would I actually raise an error which happens inside a vue component?

@dts
Copy link
Author

dts commented Aug 13, 2018

@siegy22 - Some more context would be helpful. My guess is that you may be able to set your own error handler, and hook that up to cypress. Letting exceptions "escape" is usually not ideal - they should be caught and reported somewhere, and that's what the error handler is for.

f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants