mattinsler/longjohn

Q seems to truncate the stack trace

Closed this issue · 1 comments

The call stack ends with Q - anything that called the promise doesn't appear in the call stack.

    at callback (/server/node_modules/q/q.js:1398:37)
    at makePromise.makePromise.fapply (/server/node_modules/q/q.js:745:27)
    at makePromise.promise.promiseSend [as promiseSend] (/server/node_modules/q/q.js:546:41)
    at exports.dispatcher (/server/node_modules/q/q.js:1036:28)

Try this code out.

require('longjohn');
Q = require('q');

function foo() {
console.log('hey!');
}
function bar() {
throw new Error('error!');
}
function success() {
console.log('success!');
}
function error(err) {
console.log('error!');
console.log(err.stack);
}

Q.fcall(foo).then(bar).then(success, error).end();

This should work just fine. However, if you require longjohn after you require q, then it won't work. Looks like q copies or changes the nextTick method so you need to make sure that longjohn can manipulate it before q does.