raygun4js icon indicating copy to clipboard operation
raygun4js copied to clipboard

Raygun ignores Syntax errors during page loading when `ignore3rdPartyErrors` enabled

Open Obi-Dann opened this issue 4 years ago • 3 comments

Hello,

I have ignore3rdPartyErrors enabled to reduce the noise from browser extensions, but it also prevents errors caught during the initial JS bundle loading to be ignored. Before rg4js is loaded, it attaches a handler to window.onError, but it ignores every bit of useful information there only using the value of msg which is just a string that does not have any stack trace. https://github.com/MindscapeHQ/raygun4js/blob/a3f9b66d78ae016480e2ced438c365e6494d9601/src/umd.intro.js#L22-L33

Because the error does not have stack trace, it gets ignored by ignore3rdPartyErrors.

Possible solution would be to extend that error with other data from onError like line number, filename etc and stop that error from being ignored by ignore3rdPartyErrors

Obi-Dann avatar Sep 01 '20 03:09 Obi-Dann

Thanks for filing the issue @Obi-Dann.

I can see how what you are describing could occur but from my understanding it would only happen if the onerror event doesn't provide a Error object. Upon which we then instantiate our own Error instance, which could be missing that information.

Not saying it's not a case we should not cater towards, but that I'd like to first know (or remember) when that object is not available :)

BenjaminHarding avatar Sep 01 '20 21:09 BenjaminHarding

I narrowed it down to SyntaxErrors. When SyntaxError is thrown, onerror has the error object but it's quite useless - there's no stack and hardly any useful information in the error object. Other parameters on the other hand have lots of useful info: filename, lineno and colno all populated with correct details. I wonder if SyntaxErrors should be treated differently in onerror handler. Going to experiment a bit more and see if I can come up with a simple solution

Obi-Dann avatar Sep 02 '20 01:09 Obi-Dann

Interesting findings @Obi-Dann! I'll be interested in what you find out :)

BenjaminHarding avatar Sep 02 '20 02:09 BenjaminHarding