Hacker News new | ask | show | jobs
by pornel 3359 days ago
It doesn't matter. The problem is that `callback(null)` throws, and in the `Promise` land this will never result in an uncaught exception. An exception directly inside any `Promise` callback produces another `Promise` in the chain instead.

You could at best use `setTimeout` or `nextTick` to escape from `Promise`'s call stack and throw there.

1 comments

Good point! I thought of solving the callback getting called twice problem and didn't think of the bigger picture that mocha needs to catch the assertion error. I like the setTimeout/nextTick trick (well, ideally use Promises and async/await instead).