Skip to content

Instantly share code, notes, and snippets.

@pehlert
Last active August 29, 2015 14:27
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 pehlert/d6541bf0681d640cfeaf to your computer and use it in GitHub Desktop.
Save pehlert/d6541bf0681d640cfeaf to your computer and use it in GitHub Desktop.
/*
* The promise "inner" should reject due to the ReferenceError that is inevitably thrown in line 13.
* There is no reject handler for "inner", because it is called as part of another promise chain "outer".
* However, the "outer" promise is being *resolved* and inner's rejection remains unhandled.
* To make this more weird, if in line 16 instead of "inner", "Promise.reject()" is returned,
* the outer promise will be rejected just fine.
*/
var inner = Promise.resolve(),
outer = Promise.resolve();
inner.then(function() {
return thisNameDoesNotExist;
});
outer.then(function() { return inner; })
.then(function() { console.log("resolved"); }, function(e) { console.log("rejected", e); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment