Skip to content
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

Failures get swallowed and lost. #74

Open
johnjbarton opened this issue Oct 1, 2013 · 3 comments
Open

Failures get swallowed and lost. #74

johnjbarton opened this issue Oct 1, 2013 · 3 comments

Comments

@johnjbarton
Copy link

When I debug the example below I see that wrap() swallows the exception even in the case that no rejection handlers are registered. This is not a good thing: consider that the function that throws here could be many libraries away and know nothing about Promises.

var testResult = (function () {
  var p = new Promise(function(r) {
    setTimeout(function() {
      r.resolve();
    }, 10);
  });
  p.then(function() {
    throw new Error('blam');
  });
  return p;
})();
testResult.then(function(value) {
  console.log("success");
}, function(error) {
  console.error(error);
});
@neonstalwart
Copy link

am i right that p is not rejected - it's var p2 = p.then( ... ) which is rejected and testResult is p not p2?

@johnjbarton
Copy link
Author

testResult is certainly p. Something is rejected but I have no way to know if it is the return value of p.then().

That p.then() is an internally created Promise helps explain this bug from a naive dev's point of view: if the system is creating promises and I am not resolving them it can't be a good result.

@johnjbarton
Copy link
Author

This issue is discussed on http://documentup.com/kriskowal/q/ where they recommend using the .done() function to ensure that exceptions are reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants