Closed AlexGalays closed 9 years ago
No it doesnt swallow all errors does it!? There was a bug but with latest version there should not be such behavior
I'm using the latest version :(
And you say exceptions are hidden? Any example?
Well, the good news is I can't reproduce it. Perhaps I was not generating errors but only undefined values...
Ok, I reproduced it. It seems to involve fromPromise
even though the error is thrown in a mapped stream. I guess that's because all the downstream user code is called within the then
of the A+ promise, which catches any error.
Try this at requirebin:
var Bacon = require('baconjs');
var Q = require('q');
var as = Bacon.fromArray([1, 2, 3]).flatMap(function(num) { return Bacon.fromPromise(Q(num)) });
var bs = as.scan(10, function(a, b) { return a() + b }); // a is a Number but a() doesn't throw an error
bs.onValue(function(b) {
console.log(b);
});
true! needs investigation.
oh, it's Q that's swallowing the exception, not Bacon :)
Yes and no :p
Q or any A+ promise implementation will by design swallow an exception in a then
success handler if no other action is taken (in the case of Q, you would have to use done()
to advice the promise chain is over and all errors have been handled).
Since bacon only relies on the presence of a 'then' function, I think the only action possible is for it to add a try-catch that call the same thing as the error handler.
This is duplicate to #501
Fixed in 0.7.50
When in dev mode, it would be very useful to have a global, catch-all error handler since bacon swallow all errors. A tiny error in a map() somewhere downstream, and nothing happens, no stream is consumed, no error is thrown.
It could be used as follow: