Menu

Why errors are not bubbling up from ES6 promises? (+fix)

I’ve just spent way to much time debugging a node program that was crashing because of a database call wrapped in ES6 promise. After looking all around in my code for an abusive try/catch silencing the error, I stumbled upon an article explaining error handling behavior with ES6 promises, that are just basically “swallowing” all errors thrown during their resolution. While arguable, this behavior is expected as per the specifications.

A (safer) promises wrapper

Meanwhile, I’ve put together a wrapper for ES6 Promise, that displays errors as they are raised. I published it on npm as safe-promise. Just use this as your promise lib, and you’ll get the errors back.