In Promise-based asynchronous code, rejections are used for error handling. One risk is that rejections may get lost, leading to silent failures. For example:
function main() {
asyncFunc()
.then(···)
.then(() => console.log('Done!'));
}
If asyncFunc() rejects the Promise it returns then that rejection will never be handled anywhere.
Let’s look at how you can track unhandled rejections in browsers and in Node.js.