It’s very hard to debug a crash when no stack traces are printed. It becomes a case of manually trying to find the error.
GET /foo/bar/ Doing something useful Error: Expected } near ;
ES6 promises doesn’t seem to offer the functionality to change this,
and bluebird has
on[Possibly]UnhandledRejection, which can only be
used if you don’t add a
.catch() case to the promise. There is no global
callback for a rejection unless it’s unhandled. To workaround this, we’re
going to need to override the method which runs the callbacks. This is a
little hacky, and relies on the library not changing - but it’s better than
First, if you haven’t already, install Bluebird.
Next, make a file somewhere (perhaps called bluebird.js) with this as its contents:
Alternatively you could just print reason.stack if it exists, however I prefer
a full crash whilst debugging. You could also make it possible for promises
to declare whether they should throw errors - similar to the
in Java - and print out the stack rather than crashing in that case.