Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Stack trace column number incorrect if error is thrown on line 1 #9445

@rogierschouten

Description

@rogierschouten

It seems that node internally prepends some code to wrap a script into a module. However, it fails to correct for this in the stack traces of any errors that occur on line 1 of a script. This manifests itself e.g. in uglified files where EVERYTHING is on line 1 of the script. This renders sourcemaps useless.

Example:

throw new Error("bla");

Output (note the column number of the first stack frame is larger than the line in the code):

c:\issue.js:1
(function (exports, require, module, __filename, __dirname) { throw new Error(
                                                                    ^
Error: bla
    at Object.<anonymous> (c:\issue.js:1:69)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:935:3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions