async-profile icon indicating copy to clipboard operation
async-profile copied to clipboard

Always print AsyncProfile.create

Open clevertension opened this issue 11 years ago • 5 comments

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

clevertension avatar Nov 24 '14 02:11 clevertension

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.

spifd avatar Dec 01 '14 15:12 spifd

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.

ConradIrwin avatar Dec 03 '14 18:12 ConradIrwin

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

clevertension avatar Dec 04 '14 11:12 clevertension

Same problem here…

qraynaud avatar Dec 28 '14 15:12 qraynaud

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.

lfdoherty avatar Jan 09 '15 11:01 lfdoherty