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
Promise.join
calls callback synchronously
#1153
Comments
Also, if no promises are provided, the callback doesn't run at all: Promise.join( function(a, b, c) {
console.log( {a: a, b: b, c: c} );
} );
console.log('next sync statement');
It would be pretty pointless for someone to call |
Any plans to backport this to bluebird v2.x? The issue remains in v2.10.2. |
Sure |
OK great. I've raised a separate issue for my second point about the callback not being called if no promises are provided. #1218 |
I'm not sure if we should fix this in 2.0, if there is someone in the wild who is doing this (for whatever weird use case) it'd be a behavior change for them. |
Just thought I'd mention myself as such a person -- and yes, it's a kind-of weird use case. (though it's only for debugging code, of course) Anyway, for how to restore this synchronous behavior (in my case, for a stack-trace processing library with external source-maps), see here: stacktracejs/stacktrace.js#188 |
Please answer the questions the best you can:
v2.10.2, v3.4.1
Node v6.2.1, OS X 10.9.5
Yes, consistent across v2.x and v3.x
Promise.join
's behavior in when it calls the callback (final argument) depends on the state of the promises it's passed. If all promises are resolved, it runs the callback synchronously; but if any of the promises are pending, it runs callback async.outputs:
But:
I'm not completely sure of the intended behavior, but I tend to think that this unpredictability isn't ideal and the callback should never be called synchronously.
The text was updated successfully, but these errors were encountered: