Skip to content

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

@fogine

Description

@fogine

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions