stackdriver-errors-js icon indicating copy to clipboard operation
stackdriver-errors-js copied to clipboard

Error string normalization

Open ubershmekel opened this issue 8 years ago • 7 comments

I'm not sure if this is within the scope of this project or not. But I did notice that different browsers will have different error strings for the same error. E.g.

ReferenceError: Can't find variable: errorHandler in Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.79 Mobile/14A456 Safari/602.1

vs

ReferenceError: errorHandler is not defined in Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.70 Safari/537.36

The full stack trace isn't the exact same either, just function names differ I think:

ReferenceError: errorHandler is not defined
at <anonymous> (https://redditp.com/js/script.js:615)
at Object.success (https://redditp.com/js/EmbedIt.js:94)
at i (https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js:2)
at Object.fireWith (https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js:2)
at z (https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js:4)
at HTMLScriptElement.c (https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js:4)
at HTMLScriptElement.dispatch (https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js:3)
at HTMLScriptElement.r.handle (jquery.min.js:3)

vs

ReferenceError: Can't find variable: errorHandler
at <anonymous> (https://redditp.com/js/script.js:615)
at success (https://redditp.com/js/EmbedIt.js:94)
at i (https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js:2)
at fireWith (https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js:2)
at z (https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js:4)
at c (https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js:4)
at dispatch (https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js:3)
at handle (https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js:3)

ubershmekel avatar Dec 02 '17 20:12 ubershmekel

This seems a very relevant suggestion.

I would encourage to build this feature into https://github.com/stacktracejs/stacktrace.js/, which is the library this module uses.

CC @eriwen

steren avatar Dec 03 '17 00:12 steren

Thanks for pinging me @steren. There is an error-stack-normalizer module made to work with stacktrace.js that may at least normalize function names.

Having this built in to stacktrace.js has been requested now a few times now. What would really, really help me out for such a thing is test cases; stack traces across various browsers from a couple projects would be killer. Would one of you folks be willing to provide some?

eriwen avatar Dec 04 '17 03:12 eriwen

Thinking about this more: isn't the goal to determine if 2 errors semantically the same? Would it be more useful to have a tool that spit out something like a similarity score instead?

eriwen avatar Dec 04 '17 03:12 eriwen

The Stackdriver Error Reporting backend groups errors based on complex heuristics, looking at their stacktraces and message.

However, it does not do a good job for browser-based errors, as it does not expect the same code to produce messages that varies.

steren avatar Dec 04 '17 03:12 steren

And this can vary even in the same browser, as far as I remember Microsoft one used to throw messages in users language version (this is I18n with capital I ;))

Jastrzebowski avatar Dec 11 '17 22:12 Jastrzebowski

If I read into your comment correctly @steren, normalization only would be most helpful for you.

eriwen avatar Dec 15 '17 03:12 eriwen

For Stackdriver Error Reporting: yes, the backend already has some grouping function that decides if two errors events are the same error. However, it expects normalized errors the same code error should have the same stack, independently from the browser.

steren avatar Dec 15 '17 03:12 steren