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 Promises swallow errors!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.

The following article describes this behavior quite well and provide a workaround: http://jamesknelson.com/are-es6-promises-swallowing-your-errors/

Continue reading