Skip to content

Instantly share code, notes, and snippets.

@bjoerge
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerge/2b856720b16a4d67e29b to your computer and use it in GitHub Desktop.
Save bjoerge/2b856720b16a4d67e29b to your computer and use it in GitHub Desktop.
// Can you spot the bug? You will never se any errors in devtools/console when running this.
new Promise(function(reslove) {
resolve("Foo");
})
.then(function() {
console.log("Why is this never called?");
});
@avoidwork
Copy link

You have a typo... reslove vs resolve.

@avoidwork
Copy link

Two ways to 'do it right'...

1: not ideal, but functional...

new Promise(function(reslove) {
  resolve("Foo");
})
.catch(function (e){ console.log(e); })
.then(function() {
  console.log("Why is this never called?");
});

2: doing it right

new Promise(function(reslove) {
  resolve("Foo");
})
.then(function() {
  console.log("Why is this never called?");
}, function (e) { console.log(e); });

@bjoerge
Copy link
Author

bjoerge commented Sep 11, 2014

My point was that typos like this are (currently) swallowed silently and not being reported to devtools/console (at least in Chrome/FF).

Relevant: domenic/promises-unwrapping#19
Chromium issue: https://code.google.com/p/v8/issues/detail?id=3093

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment