Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

parsed stack trace is missing the source location of thrown Error #29

Open
fogine opened this issue Aug 29, 2018 · 0 comments
Open

parsed stack trace is missing the source location of thrown Error #29

fogine opened this issue Aug 29, 2018 · 0 comments

Comments

@fogine
Copy link

fogine commented Aug 29, 2018

The following pseudo code:

try {
    fnWhichThrows();
} catch(e) {
    console.log(e.stack);
    console.log(stackTrace.parse(e));
}

console.log(e.stack) prints:

/path/to/source/file.js:22
(*$&@#(*!route.validate();
 ^
        
SyntaxError: Unexpected token *
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    ...

console.log(stackTrace.parse(e)); prints:

[ { column: 10,     
    file: 'vm.js',                                                                       
    function: 'createScript',
    line: 80,         
    method: null,            
    native: false },                                                                     
  { column: 10,               
    file: 'vm.js',  
    function: 'Object.runInThisContext',
    line: 139,                                                                           
    method: 'runInThisContext',
    native: false },
    ....
]

Meaning, the parsed call stack doesn't include:

/path/to/source/file.js:22
($&@#(!route.validate();
^

which is the most important part of the stack.
In practice, this happens when require('package-name'); throws due to eg.: syntax error in the package's index.js file...
I see HERE that node-stack-trace always skips the first line of the call stack, why is that so?

Node version: 8.11.3

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant