Last active
May 24, 2018 12:41
-
-
Save getify/bd11ccf1eff2efdac0fb to your computer and use it in GitHub Desktop.
more Promise confusion/inconsistency (or implementation bugs?)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Just an update for posterity: | |
These bugs have been fixed by implementations and all 6 of these examples | |
work fine in current Chrome, Firefox, and Safari (checked on May 24, 2018). | |
*/ | |
Promise.reject(42).then(null,null).then(null,function(reason){ | |
console.log("reason:" + reason); | |
}); // reason:42 | |
Promise.reject(42).then(5,null).then(null,function(reason){ | |
console.log("reason:" + reason); | |
}); // reason:42 | |
Promise.reject(42).then(null,5).then(null,function(reason){ | |
console.log("reason:" + reason); | |
}); // TypeError: number is not a function | |
// ************* | |
Promise.resolve(42).then(null,null).then(function(msg){ | |
console.log("msg:" + msg); | |
},null); // msg:42 | |
Promise.resolve(42).then(null,5).then(function(msg){ | |
console.log("msg:" + msg); | |
},null); // msg:42 | |
Promise.resolve(42).then(5,null).then(function(msg){ | |
console.log("msg:" + msg); | |
},null); // (nothing printed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@domenic confirmed all 6 should work, so this reveals bugs in Chrome/v8, which also means node's (v0.11.x, 0.12.x) Promises will be buggy until fixed. There may be other bugs in the browser too, as it doesn't appear that browsers are running the full test-suite against their implementations. :(