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
Promises resolve in wrong order #1026
Closed
danieltroger opened this issue
Dec 20, 2021
· 5 comments
· Fixed by majacQ/core-js#4 or majacQ/core-js#5
Closed
Promises resolve in wrong order #1026
danieltroger opened this issue
Dec 20, 2021
· 5 comments
· Fixed by majacQ/core-js#4 or majacQ/core-js#5
Comments
I was able to reproduce it. Most likely it's an issue in the scheduler since it happens in IE and old V8, but not in old Safari. |
Transpiling and async functions are not requied, we can simplify it to function the_thing() {
const resolved_promise = Promise.resolve();
return function(value) {
console.log("Function for", value, "is awaiting resolved promise");
resolved_promise.then(function () {
console.log("Function for", value, "continued");
});
};
}
const fn1 = the_thing();
const fn2 = the_thing();
fn2(1);
fn1(2); |
Or even to var p1 = Promise.resolve();
var p2 = Promise.resolve();
p2.then(function() { console.log('should be first') });
p1.then(function() { console.log('should be second') }); |
Now, unlike
|
Fixed in 3.20.1. |
This was referenced Jan 16, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AFAIK Promises are supposed to be deterministic. And as part of that, resolve in the order they were created.
I have found a case where that's not the case with the transpiled version, running in IE11.
It behaves differently from when executing it unpolyfilled in a normal browser.
Continuation of #1025 as issue
Input code snippet:
Expected output:
Actual output, when ran in IE11:

Transpiled code that I executed in IE11 (transpiled with parcel):
How to transpile: Go to https://babeljs.io/repl/#?browsers=ie%2011&build=&builtIns=entry&corejs=3.6&spec=false&loose=false&code_lz=LYQwlgdgFAlA3AKASAzgTwgYwAQDMCuWALmAPYTaiSzYDeC22m5KReEAjNgLzZEAWAUwD6AyAHNYiRswit2AJh58ho_hKkNFUDvC25OUBXoC-SAsTIUBIsREkw6W2fIBOglKQA2AN0EATYQAHV1JgMBRBZQAFUPDIgDp3T19BTUZ3InxXClQMHB8QL3wo7gA-J0YZFm9BBK9SSQAiADFCTBJyPFJXJoAabELiwQGmiOwQAHdwEntsZO8_f2wQsIjBJr0qiemwNgXUwNX4wWkql1r6xqhW9s6KXB7-waKS0dlZkv9Ns5NEEyAA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=true&fileSize=false&timeTravel=false&sourceType=module&lineWrap=false&presets=env%2Ctypescript&prettier=false&targets=&version=7.16.6&externalPlugins=&assumptions=%7B%7D
Copy the contents of https://unpkg.com/core-js-bundle@3.20.0/index.js and https://unpkg.com/regenerator-runtime@0.12.1/runtime.js and the result to the right from the babel REPL into a js file and run it in IE11
The text was updated successfully, but these errors were encountered: