'Retroactively get original column:error using a source map

When running our Selenium tests on our webapp we get access to the console logs in case the javascript crashes, which typically looks like this:

09:27:09.540 [main] ERROR gui.rule.ScreenshotRule - Chrome console: SEVERE https://localhost:56962/bundle.js 94:74996 TypeError: Cannot read property 'map' of undefined

Now, bundle.js 94:74996 isn't all that useful on its own (though I can still use vim with some success), but we do produce source maps with the bundle build (which Chrome for some reason chooses not to use in the app crashes), which would be quite useful here. Is there a way of retroactively convert LINE:COLUMN pairs using the original source map?



Solution 1:[1]

I ended up hacking together the tool I wanted: stacktrace-cli.

Now you can do this:

npx @fatso83/stacktrace-cli app-bundle.js app-bundle.js.map 129:600036

Resulting in this output:

{
    "columnNumber": 56,
    "lineNumber": 78,
    "fileName": "webpack:///src/store/entity/entity-reducer.js",
    "functionName": "getEntitysById"
}
{
    "columnNumber": 56,
    "lineNumber": 78,
    "fileName": "webpack:///src/store/entity/entity-reducer.js",
    "functionName": "map"
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1