-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Unwrapping resolved promises don't happen asynchronously #965
Comments
The spec does not mandate the order here. You can check different platforms with native promises (like other JS engines) and get varying results. NPO and bluebird probably just use different schedulers and both results are valid. Resolution is always synchronous (promise constructor has to run synchronously) - what's "asynchronous" is the |
I'm starting to wonder if this is correct - as EnqueueJob is called on resolution itself in the spec. |
So I'm missing something. @domenic care to tell me what I'm missing in the spec? |
They are called asynchronously, just in different order. It was impossible to have same order as native promises without suffering from the memory leak native promsies suffer from (promises-aplus/promises-spec#183, promises-aplus/promises-spec#179). |
Thanks for clarifying @petkaantonov |
Sorry if this a more appropriate question for StackOverflow, thought I would ask here first.
Not sure if this was mentioned before, but I was reading @getify You Don't Know JS - Async & Performance and came across the following example which seems to behave differently using
bluebird
than using the author'snative-promise-only
promise library.The following code snippet is a
node.js
program that has previously installed the following:npm install --save-dev native-promise-only bluebird
Output after running:
@getify states that according to spec (still looking for the source):
I've also ran the code snippet in a ES6 fiddle to see what happens and get the same behavior as using
native-promise-only
.Question
I understand that this is quirky behavior and in general one should not assume anything about the order of callbacks, but can anyone comment on why
bluebird
promises behave this way? Is it for performance?The text was updated successfully, but these errors were encountered: