sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

I cannot prevent the NotAllowedError error from being sent.

Open barisyild opened this issue 2 years ago • 6 comments

Is there an existing issue for this?

  • [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [X] I have reviewed the documentation https://docs.sentry.io/
  • [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/browser

SDK Version

latest

Framework Version

No response

Link to Sentry event

No response

Steps to Reproduce

Sentry.init({ dsn: '...', tracesSampleRate: 1.0, ignoreErrors: [ /NotAllowedError/ ], });

It works in some browsers, but not in others. (Especially safari)

Expected Result

NotAllowedError should not be sent to the sentry server.

Actual Result

NotAllowedError sends it to the sentry server.

barisyild avatar Jun 15 '22 18:06 barisyild

Hey, thanks for writing in! I made a quick reproduction of trying to ignore NotAllowedErrors and could not reproduce your result: https://codesandbox.io/s/notallowederror-test-mnmwku?file=/src/index.js

Example from Safari

image

Could you provide a link to your Sentry error or give some kind of reproduction so we can investigate further?

AbhiPrasad avatar Jun 15 '22 19:06 AbhiPrasad

Hey, thanks for writing in! I made a quick reproduction of trying to ignore NotAllowedErrors and could not reproduce your result: https://codesandbox.io/s/notallowederror-test-mnmwku?file=/src/index.js

Example from Safari

image

Could you provide a link to your Sentry error or give some kind of reproduction so we can investigate further?

https://codesandbox.io/s/notallowederror-test-forked-stx784?file=/src/index.js

Windows Chrome Output:

message: NotAllowedError: Permission denied

iOS Safari Output:

message: undefined

barisyild avatar Jun 15 '22 20:06 barisyild

https://codesandbox.io/s/notallowederror-test-forked-stx784?file=/src/index.js

Windows Chrome Output:

message: NotAllowedError: Permission denied

iOS Safari Output:

message: undefined

if you uncomment the ignoreErrors option, you'll see the errors get ignored (Sentry logger in the console). This works on Chrome, Safari, Firefox.

message is undefined on purpose here since we are capturing an error using Sentry.captureException, not a message with Sentry.captureMessage.

See the inbound filters code that uses ignoreErrors: https://github.com/getsentry/sentry-javascript/blob/ef30920004f4b843db34c3c9705e3d9c9cb06218/packages/core/src/integrations/inboundfilters.ts#L133-L147

If you log out event.exception in the beforeSend option, you can see that it is defined:

{"values":[{"type":"NotAllowedError","value":"The request is not allowed by the user agent or the platform in the current context.","mechanism":{"type":"generic","handled":true}}]} 

AbhiPrasad avatar Jun 15 '22 20:06 AbhiPrasad

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

github-actions[bot] avatar Jul 07 '22 00:07 github-actions[bot]

/AbortError/ does not ignore, how can i fix?

image

barisyild avatar Jul 07 '22 20:07 barisyild

Using ignoreErrors: ['AbortError'] should work here.

AbhiPrasad avatar Jul 07 '22 20:07 AbhiPrasad