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

Thrown error is silenced when rejection is not caught #3

Closed
slavafomin opened this issue Sep 8, 2016 · 2 comments
Closed

Thrown error is silenced when rejection is not caught #3

slavafomin opened this issue Sep 8, 2016 · 2 comments

Comments

@slavafomin
Copy link

Hello!

Thank you for this great module!

However, I have some unexpected behavior with thrown errors: when I throw an error from inside of action function, it's silenced somehow when the rejection is not caught.

Here's the simplified example:

const Promise = require('bluebird');
const promiseDoWhilst = require('promise-do-whilst');


foo().then(result => console.log('Result', result));
// Error is displayed in the console.

bar().then(result => console.log('Result', result));
// Error is ignored, no output.


function foo () {
  return Promise.resolve().then(() => {
    throw new Error('Some error');
  });
}

function bar () {
  return promiseDoWhilst(() => {
    throw new Error('Some error');
  }, () => true);
}

I do prefer to see all thrown errors in the output of the Node.js application.

Thanks!

@slavafomin
Copy link
Author

The workaround would be right now to call promiseDoWhilst() this way:

const Promise = require('bluebird');

return promiseDoWhilst(action, condition)
  .catch(rejection => Promise.reject(rejection))
;

@busterc
Copy link
Owner

busterc commented Dec 19, 2017

I believe node v6+ processes unhandled promise exceptions in the manner you were expecting. Otherwise, as you noted, indeed the expectation is to provide a catch handler if you wish.

See also: nodejs/node#830

@busterc busterc closed this as completed Dec 19, 2017
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