-
Notifications
You must be signed in to change notification settings - Fork 78
What is correct execution sequence when attach multiple handlers to the same promise. #34
Comments
Both. No, seriously. Both. There's actually no standard (nor will there be, apparently) that talks about the semantics of ordering between two different promises, only within a single promise. There's just simply no guarantees that can be made across two or more promises in any general sense. See these threads for more info on this: |
@getify Thanks! |
That's not correct. Promises/A+ does not give a standard for that, but ES6 does. The second set of results are correct per spec, due to the nature of the microtask queue as FIFO. |
I apologize for too quickly skipping validating your original question and jumping to a conclusion. I should have checked that what you were asking was in fact valid. See below...
Actually, that's not how NPO behaves. NPO behaves in this case exactly as you quoted Chrome and @domenic's reference implementation: Here, go try it yourself. :) I'm not sure if perhaps you were using an older NPO, or if perhaps you thought you were testing NPO but weren't actually, since it by-default is a polyfill that only installs itself if the global |
I suggested/asserted exactly this multiple times in those earlier linked discussions, as well as in other (not linked) discussions about creating the ES6 Promise test suite in particular. As you'll recall I was repeatedly told (as those earlier links clearly show) that no such semantic was intended between promises. It was implied as an indirect side-effect of the FIFO queue usage that there might be special cases (like this OP) where inter-promise sequencing was predictable. If generalized inter-promise sequencing is totally expectable and reliable, why then was there pushback to my suggestion to create a ES6 test for inter-promise sequencing? This particular example (being simplified as it is) is explainable (and predictable) directly through FIFO reasoning, I agree. But in the general case where promises are resolving at different times, again as those earlier linked discussions asserted, there should be no reliance on inter-promise sequencing. "Tests, or it didn't happen." If the spec implies something but there's no test to verify and guarantee it, I don't consider it a valid requirement. So, if there's since been an ES6 test designed for inter-promise sequencing, I apologize -- I certainly have tried to keep up to speed on these issues, and I clearly wanted such a test back when I was pushing for it. But until there is definitely such a test, I stand by the assertion that people should not rely on the general case of inter-promise sequencing. |
Those earlier discussions were all within the context of Promises/A+, not ES6 promises. I don't see anything in my replies in the linked threads that pushes back against any work on an ES6 test suite done independently from Promises/A+. |
Oh... my bad. native-promise-only work fine! |
I've filed FF #1062323 about the incorrect ordering. I would imagine that bug won't get fixed until there's an agreed conformance test, but... shrugs. |
The test case(in general, bad case...):
The result of Firefox 35.0a1
and native-promise-only:The result of Chrome 37.0.2062.94 , @domenic's reference-implementation (code) and native-promise-only:
Which is correct?
The text was updated successfully, but these errors were encountered: