AndreasMadsen / trace

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

Compatibility with Node 4 #14

Closed julien-f closed 8 years ago

julien-f commented 8 years ago

It does not seems to work on my side, am I wrong?

AndreasMadsen commented 8 years ago

It should work. I have used it myself with node 4. Can you show me an example of something that doesn't work?

julien-f commented 8 years ago

My bad, it works ^^

julien-f commented 8 years ago

In fact I have a problem writing my own filter for stack-chain and I get all kind of errors which I have a hard time debugging.

Here is my code:

var sep = require('path').sep
var path = __dirname + sep + 'node_modules' + sep

require('stack-chain').filter.attach(function (_, frames) {
  var filtered = frames.filter(function (frame) {
    var name = frame && frame.getFileName()

    return (
      // has a filename
      name &&

      // contains a separator (no internal modules)
      name.indexOf(sep) !== -1 &&

      // does not start with the current path followed by node_modules.
      name.lastIndexOf(path, 0) !== 0
    )
  })

  // Do not returns an empty stack as it messes up with depd.
  return filtered.length
    ? filtered
    : frames
})

Sometimes depd complains because the stack is empty (which I tried to fix with the ternary operator) and sometimes because the first frame is undefined which should not be a result of my code :/

Any ideas?

julien-f commented 8 years ago

Ok, It looks like depd requires at least 3 frames in the stack.

Thanks anyway :)