raygun4js
raygun4js copied to clipboard
Raygun ignores Syntax errors during page loading when `ignore3rdPartyErrors` enabled
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
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 :)
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
Interesting findings @Obi-Dann! I'll be interested in what you find out :)