Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raygun ignores Syntax errors during page loading when ignore3rdPartyErrors enabled #371

Open
Obi-Dann opened this issue Sep 1, 2020 · 3 comments

Comments

@Obi-Dann
Copy link

Obi-Dann commented Sep 1, 2020

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.

windw.onerror = function (msg, url, line, col, err) {
if (originalOnError) {
originalOnError(msg, url, line, col, err);
}
if (!err) {
err = new Error(msg);
}
windw['rg4js'].q = windw['rg4js'].q || [];
windw['rg4js'].q.push({e: err});
};

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

@BenjaminHarding
Copy link
Contributor

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 :)

@Obi-Dann
Copy link
Author

Obi-Dann commented Sep 2, 2020

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

@BenjaminHarding
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants