fix: propagates user rejection errors (#6533)

This commit is contained in:
Vignesh Mohankumar 2023-05-11 19:40:02 -04:00 committed by GitHub
parent 3733570a89
commit 4fc4bdcd55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 9 deletions

@ -74,6 +74,11 @@ describe('filterKnownErrors', () => {
expect(filterKnownErrors(ERROR, { originalException })).toBe(ERROR)
})
it('propagates user rejected request errors', () => {
const originalException = new Error('user rejected transaction')
expect(filterKnownErrors(ERROR, { originalException })).toBe(ERROR)
})
it('filters block number polling errors', () => {
const originalException = new (class extends Error {
requestBody = JSON.stringify({ method: 'eth_blockNumber' })
@ -86,11 +91,6 @@ describe('filterKnownErrors', () => {
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
it('filters user rejected request errors', () => {
const originalException = new Error('user rejected transaction')
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
it('filters invalid HTML response errors', () => {
const originalException = new SyntaxError("Unexpected token '<'")
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()

@ -1,5 +1,4 @@
import { ClientOptions, ErrorEvent, EventHint } from '@sentry/types'
import { didUserReject } from 'utils/swapErrorToUserReadableMessage'
// `responseStatus` is only currently supported on certain browsers.
// see: https://caniuse.com/mdn-api_performanceresourcetiming_responsestatus
@ -80,9 +79,6 @@ export const filterKnownErrors: Required<ClientOptions>['beforeSend'] = (event:
// If the error is a network change, it should not be considered an exception.
if (error.message.match(/underlying network changed/)) return null
// If the error is based on a user rejecting, it should not be considered an exception.
if (didUserReject(error)) return null
// This is caused by HTML being returned for a chunk from Cloudflare.
// Usually, it's the result of a 499 exception right before it, which should be handled.
// Therefore, this can be ignored.