-
Notifications
You must be signed in to change notification settings - Fork 2.3k
promisified function does not trigger setScheduler #1023
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
Comments
I just tested the same jsfiddle with bluebird v2.10.2 and it worked as expected. Upgrading it to 3.0.0 breaks it. |
This is an optimization because the promisifier can tell when scheduler is not needed |
Can you explain a little further? Why is the scheduler not needed in this case? |
Automatic promisification only applies to functions with the node As for what Petka is saying - bluebird will eagerly avoid defering actions when it can prove that the action has already been deferred by the platform. That is - in this case it can tell the action inside the promisified callback has executed asynchronously so it does not need to defer it further. This should not be an issue with Angular since automatic promisification is irrelevant to it anyway. |
@benjamingr Thank you for the explanation. I guess my use case is a little unique in that I'm using Electron (http://electron.atom.io/) which means node style callbacks are common and may propogate up to angular (due to node modules being available from the "client-side"). |
Oh, interesting - you can probably work around it with monitoring turned on and scheduling a noop evalAsync when promises resolve - I wonder if the optimization should be opt out. |
I will have to try out the monitoring. Opt out would be nice since for now I've just downgraded bluebird to 2.x |
I just got bit by this, as well. Same use case - Electron. I have also had to downgrade to bluebird@2.10.2. |
I guess the optimization could be disabled when custom scheduler is in use. You are all using custom setScheduler right? |
Yes, I am using a custom scheduler |
Correct. |
bluebird 3.3.3, Chrome 48, angular 1.5.0
Example in this fiddle: https://jsfiddle.net/Lmac0kLw/5/
When using promisify on an async function, it appears that
setScheduler
is not called when the promise resolves. In my jsfiddle, I use angular to update the text toHelloWorld
, but it does not change.There are a few ways to remedy this:
$scope.$apply();
which obviously defeats the purpose ofsetScheduler
.pAsync
:As I understand it, there should be no difference between the promisified call vs the normal promise. Is this an actual bug? Or am I not understanding something?
The text was updated successfully, but these errors were encountered: