Always print AsyncProfile.create
0.127: 0.455ms at AsyncProfile.create (/Users/dan/test-async-profile/node_modules/async-profile/lib/index.js:61:27) (0.072)
5.560: 2.849ms at AsyncProfile.create (/Users/dan/test-async-profile/node_modules/async-profile/lib/index.js:61:27) (0.169)
8.590: 0.006ms at AsyncProfile.create (/Users/dan/test-async-profile/async-profile/lib/index.js:61:27) (0.000)
8.600: 0.003ms at AsyncProfile.create
I have the same problem after a short test in my app. Haven't tried on unit test. I'm using a promise chain using when.js and I also have only AsyncProfile.create displayed instead of actual functions.
The bug is probably in this code: https://github.com/ConradIrwin/async-profile/blob/master/src/result.coffee#L57-L72
Please let me know if you can reproduce it with a small example (or even debug it yourself ;), the code goes to some lengths to avoid this happening.
hi ConradIrwin, i think the root cause of this issue is "err = new Error()", we should create error in the callback context, not async-profile itself, for example:
a.test(param1, function(b) {
var err1 = new Error();
b.test(param2, function(c) {
var err2 = new Error();
c.test(param3, function(d) {
var err3 = new Error();
//....
}
});
});
but when i review your code, the error is created inside async profile, so it will always print this code
Same problem here…
The bug seems to be because the NPM version (0.4.0) is different from the version on GitHub. NPM's second lines loop, corresponding to this: https://github.com/ConradIrwin/async-profile/blob/master/src/result.coffee#L69 uses this test in its Javascript version: if (l.indexOf(process.cwd()) > -1) { Instead of this: if (l.indexOf(process.cwd()) > -1 && l.indexOf('async-profile') === -1) {
Correcting that line gets rid of all the "AsyncProfile.create" stuff.