AndreasMadsen / trace

Creates super long stack traces
https://trace.js.org
MIT License
194 stars 18 forks source link

TypeError: Cannot read property 'apply' of undefined #26

Closed cdaringe closed 8 years ago

cdaringe commented 8 years ago

hello! something goes awry when i run my tests using trace. i have a branch that is runnable/testable to reproduce the problem here, using good old node test/.

this file is where it's all wired up!

ok 118 run started from new db document event
/long/path/node_modules/trace/node_modules/async-hook/patches/timers.js:50
      callback.apply(this, arguments);
              ^

TypeError: Cannot read property 'apply' of undefined
AndreasMadsen commented 8 years ago

It looks like you forgot to give an function to setTimout or another timer function. Your testsuite is rather big and I have exams these weeks, so I don't have time to debug it right now, I'm very sorry.

I will get back to you after my exams on May 28.

AndreasMadsen commented 8 years ago

I have debugged the problem. As suspected you are passing undefined to setTimeout, the bug in your code is here: https://github.com/MRN-Code/coinstac-common/blob/bug/trace-crash/test/models/pipeline/runner/pool/local-pipeline-runner-pool.js#L71 you write

    local: { fn: (opts, cb) => setTimeout(cb(null, compId), 1), type: 'function' },

but I suspect you mean

    local: { fn: (opts, cb) => setTimeout(cb.bind(null, compId), 1), type: 'function' },

However there is also a bug in trace as the behaviour of passing undefined shouldn't change because of trace. In node v6 setTimeout throws a meaningful error if a non-function is passed to a timer function. In node v5 it doesn't throw, which is the version I suspect you are using.

I have decided to go with the node v6 behaviour, as it is the one I find most useful. However it will technically be a side effect of using trace if one uses node v5.

AndreasMadsen commented 8 years ago

Fixed in async-hook v1.5.0 https://github.com/AndreasMadsen/async-hook/commit/b0f67365973a2ad6534611511446e6b4d2c4e5fe

cdaringe commented 8 years ago

yea you're right. i fixed that recently, but had hence dropped trace.

thanks so much for lookin' into it. appreciate your time.