-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
How to handle silent error in dispatch? #1060
Comments
You don't need to return a result for forEach loop. |
Didn't realize it was supposed to stop in case of error … hence why I'm asking about the right approach. My main concern was surfacing the silent errors (which I'd spent way too long trying to debug, without knowing where the error was coming from) |
I think you might be misunderstanding some details of how If you have silent errors, it’s probably related to the code outside the If you're sure this is a Redux bug, please create a full reproducing example. |
Perhaps I misunderstood you. Are you saying Redux should try to invoke all listeners even if one of them failed? I'm not sure. What if many subscribers error'd? Should we just accumulate the errors? Throw just the first one and silently ignore the others? Right now our behavior is very simple—we just don't tolerate the errors at all. An app throwing an error in a subscriber is likely broken anyway, and at least we can fail hard early if this happens. If you're hesitant, you can always make a “store enhancer” (a la https://github.com/tappleby/redux-batched-subscribe) to implement the behavior you're describing. You could then publish it as a package! 😉 |
That's what I thought … but the code I posted above did surface an issue with a render method not returning a valid component, which was silently breaking otherwise. |
If it’s silently breaking, it’s a problem somewhere else, but definitely not in Redux core. |
I think there is a bug in Chrome (I'm on 68.0.3440.106). My reducer is silently breaking, and I have tracked it to this try..finally: https://github.com/reduxjs/redux/blob/master/src/createStore.js#L184 However, that syntax is fine and should not eat exceptions. If I add I'll try and reproduce this in a stand alone example, and then open a bug with Google. However, @gaearon, if you are willing to add the workaround above to redux, let me know and I'll open a PR to redux. |
Thank you @markerikson, working on it, but so far it doesn't happen in a simple example (even with some of the same modules we use). Though, I should have had a |
Ok, sorry for the noise @markerikson caused from my wrong assumption by putting a |
Currently,
dispatch
may suppress silent errors that break the program. I had this happen here:https://github.com/rackt/redux/blob/bb9fa19cf2a22d0149dcf134e36404a02d93b2b3/src/createStore.js#L126
Modifying to the following surfaces the issue.
![screen shot 2015-11-20 at 12 09 47](https://cloud.githubusercontent.com/assets/3407996/11306727/bbfe3176-8f81-11e5-840e-793a93827714.png)
I can submit a PR, but what's the recommended way to handle?
The text was updated successfully, but these errors were encountered: