← Back To API Reference

~~Promise.longStackTraces~~

This method is deprecated. Use Promise.config instead.

Promise.config({
  longStackTraces: true
})

Promise.longStackTraces() -> undefined

Call this right after the library is loaded to enable long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.

Long stack traces are enabled by default in the debug build.

To enable them in all instances of bluebird in node.js, use the environment variable BLUEBIRD_DEBUG:

BLUEBIRD_DEBUG=1 node server.js

Setting the environment variable NODE_ENV to "development" also automatically enables long stack traces.

You should enabled long stack traces if you want better debugging experience. For example:

Promise.longStackTraces();
Promise.resolve().then(function outer() {
    return Promise.resolve().then(function inner() {
        return Promise.resolve().then(function evenMoreInner() {
            a.b.c.d()
        }).catch(function catcher(e) {
            console.error(e.stack);
        });
    });
});

Gives

ReferenceError: a is not defined
    at evenMoreInner (<anonymous>:6:13)
From previous event:
    at inner (<anonymous>:5:24)
From previous event:
    at outer (<anonymous>:4:20)
From previous event:
    at <anonymous>:3:9
    at Object.InjectedScript._evaluateOn (<anonymous>:581:39)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:540:52)
    at Object.InjectedScript.evaluate (<anonymous>:459:21)

While with long stack traces disabled, you would get:

ReferenceError: a is not defined
    at evenMoreInner (<anonymous>:6:13)
    at tryCatch1 (<anonymous>:41:19)
    at Promise$_resolvePromise [as _resolvePromise] (<anonymous>:1739:13)
    at Promise$_resolveLast [as _resolveLast] (<anonymous>:1520:14)
    at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (<anonymous>:560:33)
    at Async$consumeFunctionBuffer (<anonymous>:515:14)
    at MutationObserver.Promise$_Deferred (<anonymous>:433:17)

On client side, long stack traces currently only work in recent Firefoxes, Chrome and Internet Explorer 10+.