Callback executing twice?
See original GitHub issueOriginally reported in yoshuawuyts/choo#193:
I have an effect that calls multiple effects using
run-waterfall
. The “sub” effects use thechoo/http
module to make an http request. When the requests encounter an error, theyreturn done('Bad request')
. This error message bubbles up to the parent effect, which callsdone(err)
itself, bubbling it up to the application event handler, which logs an uncaught error.The problem is the uncaught error is being logged twice. Here’s a test case to demonstrate. If you switch out the http call with the
setTimeout
call, it only logs once. Also if you comment out thedone(err)
in the parent effect, it only logs once.Am I crazy or is this unexpected behaviour?
@yoshuawuyts investigated and believes xhr
is calling the callback twice. Would it be helpful to alter the test case to demonstrate it without choo? Or is this enough to diagnose?
Thanks for your help
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Ok, found it.
Root cause is: if you throw inside xhr callback, the code that guarantees it runs only once does not execute.
I’ll have a fix for that in minutes
Yay, nice! 😁