-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
We created some tests today that were using promisified code. We observed strange behaviour when some assertions were failing. The error messages were not displayed but the stack trace was complete.
Error messages in then blocks are being truncated. This is the output for a minimal example we attached below:
bash-3.2$ node foo.js
/Users/mat/workspace/foo/node_modules/bluebird/js/main/async.js:93
throw res.e;
^
at /Users/mat/workspace/foo/foo.js:5:15
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
From previous event:
at Object.<anonymous> (/Users/mat/workspace/foo/foo.js:3:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3As you can see, the error message is missing from the output. After some debugging we found out, that it is actually present but is not written to the output (I attached the expected output containing the error message at the bottom of this issue).
This is the minimalistic example mentioned above:
var Promise = require('bluebird');
Promise.resolve()
.then(function () {
throw new Error('a$_b');
}).done();The result is especially interesting as bluebird uses the following function name: PromiseResolver$_callback. We found this string in our assertion error message.
The following cases work (replaced only the throw line, modifying the error message):
throw new Error('a$_');throw new Error('$_b');throw new Error('a$b');
These result in the correct output. E.g.:
node foo.js
node foo.js
/Users/mat/workspace/foo/node_modules/bluebird/js/main/async.js:93
throw res.e;
^
Error: a$b
at /Users/mat/workspace/foo/foo.js:5:15
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
From previous event:
at Object.<anonymous> (/Users/mat/workspace/foo/foo.js:3:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3System spec:
- bluebird version:
2.2.2and current master build - node version:
0.10.29 - zsh version:
5.0.2 - bash version:
3.2.51(1)-release - Mac OS X version:
10.9.3