Skip to content

feat: Ignore ResizeObserver and undefined error #10845

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

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/integrations/inboundfilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { convertIntegrationFnToClass, defineIntegration } from '../integration';

// "Script error." is hard coded into browsers for errors that it can't read.
// this is the result of a script being pulled in from an external domain and CORS.
const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/];
const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/, /^ResizeObserver loop completed with undelivered notifications.$/, /^undefined$/];

/** Options for the InboundFilters integration */
export interface InboundFiltersOptions {
Expand Down
33 changes: 33 additions & 0 deletions packages/core/test/lib/integrations/inboundfilters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ const SENTRY_EVENT: Event = {
},
};

const BOGUS_EVENT: Event = {
message: '',
exception: {
values: [
{
type: 'Error',
value: 'undefined',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is a scary change, in JS you never know.
But how useful can an undefined error be?

Reason I added it is because, apparently, not all ResizeObserver has a value.

Copy link
Member

@Lms24 Lms24 Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure that the undefined event is related to ResizeObserver? It might just have gotten grouped together accidentally 🤔

My concern about undefined if we're not sure is just that there could be cases where the error message is undefined (for whatever reason) but there might be a stack trace attached, making the issue more debuggable again. Suggestion: We split this PR up so we can more easily revert the undefined filter if necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - I leave undefined away for now.

},
],
},
};

const SCRIPT_ERROR_EVENT: Event = {
exception: {
values: [
Expand All @@ -188,6 +200,17 @@ const SCRIPT_ERROR_EVENT: Event = {
},
};

const RESIZEOBSERVER_EVENT: Event = {
exception: {
values: [
{
type: 'Error',
value: 'ResizeObserver loop completed with undelivered notifications.',
},
],
},
};

const MALFORMED_EVENT: Event = {
exception: {
values: [
Expand Down Expand Up @@ -294,6 +317,16 @@ describe('InboundFilters', () => {
expect(eventProcessor(SCRIPT_ERROR_EVENT, {})).toBe(null);
});

it('uses default filters Resize', () => {
const eventProcessor = createInboundFiltersEventProcessor();
expect(eventProcessor(RESIZEOBSERVER_EVENT, {})).toBe(null);
});

it('uses default filters Empty', () => {
const eventProcessor = createInboundFiltersEventProcessor();
expect(eventProcessor(BOGUS_EVENT, {})).toBe(null);
});

it('filters on last exception when multiple present', () => {
const eventProcessor = createInboundFiltersEventProcessor({
ignoreErrors: ['incorrect type given for parameter `chewToy`'],
Expand Down