mardi 23 mai 2017

Convert minified error stack to meaningfull erros using sourcemap

I need to convert minified error stack trace into meaningful errors. However, I'm having a tough time finding a library to do this locally where I can programmatically provide an error stack and source map and it does the conversion to meaningful errors.

The reason I need to provide it programmatically is because I need to use azure's app insights (stupid business requirement). The problem is that it does NOT support source mapping so errors sent are effectively meaningless and I do not want to provide source-maps publicly for obvious reasons. Idea is to send minified stack traces to backend which does the conversion and passes it forward to app-insight.

There is StackTrace.js, but there is no way of providing it a source map programmatically. There are also others such as source-map from Mozilla but it requires a fair amount of work to parse row/columns, handle stack traces from different browsers (i.e. chrome/Firefox’s stack traces are formatted slightly differently) and generate the errors manually.

Any pointers/ideas on how to tackle this, or areas to research are more than welcome.

Thanks for your time.

Example of requried result:

Source-mapped Stack trace (pointing to original code):
bork from es6
    at BabelBorker.bork (bork.es6:3:14)
    at window.babel_bork (bork.es6:7:44)
    at errorAndPrint (http://ift.tt/2qS9Mau)
    at HTMLButtonElement.onclick (http://ift.tt/2q7qeGN)
Unmapped Stack trace (pointing to transpiled code):
Error: bork from es6
    at BabelBorker.bork (http://ift.tt/2qSkqhq)
    at window.babel_bork (http://ift.tt/2q7hhwY)
    at errorAndPrint (http://ift.tt/2qS9Mau)
    at HTMLButtonElement.onclick (http://ift.tt/2q7qeGN)




Aucun commentaire:

Enregistrer un commentaire