-
Notifications
You must be signed in to change notification settings - Fork 171
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
The spec lacks definition around the order of callbacks in nested promises #92
Comments
Since Technically we don't place any time limit on when you call them though... Hmm. "must execute immediately?" @briancavalier? This is definitely a good case to add to the test suite, though! So we'll do that! |
Does that imply that a and c should be called synchronously, i.e. there should be no event loop tick between the calls for them? |
The guarantees here are: I'm not really sure what language we could add that would cover that kind of variation any better than what we have now. I do see the point, though, that an implementation that waits a really long time between calling Kind of interesting, though, since in some systems, you might actually choose a promise implementation based on how it interacts with the event loop. |
Maybe just me but even saying that is very useful for clearing it up.
Yeah we're in the process of doing exactly that. In some cases we actually need totally synchronous behaviour (though those are largely shoehorning in promises for API stability and consistency reasons) and in others we want to force as much asynchronousness as possible |
Cool, glad that helped. I'll give credit to @lsmith who said something similar over in #77, which you may find to be an interesting read as well, although it deals specifically with order, and not timing.
Just make sure to be extra careful :) Relying on any synchronous behavior between promise callbacks can create refactoring hazards. Is there anything else you feel we need to discuss for this issue? If not, please close. |
I think the sequencing can be well-determined by the requirement that then must return before any callbacks are called. As a result (in javascript), the entire line of code will be executed by any callbacks until execution returns to C++ (in the case of nextTick in 0.10.x Node) or the next pass of the event loop. For this reason, I think you can at most specify that the events are queued and run in sequence. "Immediate" here means queued for execution in an imminently future turn, but that seems dangerously beyond the scope of the specification. |
Take this example:
If a() returns a promise that is not yet fulfilled then should c still be called immediately or should it be called after newPromise is fulfilled?
The text was updated successfully, but these errors were encountered: