Created
September 19, 2018 03:35
-
-
Save KoryNunn/c7282218e5f0b90a5f7e7d1bb4ff0e01 to your computer and use it in GitHub Desktop.
Promises are broken: https://twitter.com/isntitvacant/status/1042249543926992897
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
function getValue(){ | |
return new Promise(function(resolve, reject){ | |
reject('fail'); | |
}); | |
} | |
function doX(){ | |
var x = getValue(); | |
return new Promise(function(resolve, reject){ | |
setTimeout(function(){ | |
x.then(resolve).catch(reject); | |
}); | |
}); | |
} | |
doX().then(console.log).catch(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh yeah and this absolutely fails using
async/await
too: