Commit 6d29815f authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

fix: ignore error caused by Cloudflare HTML response (#6356)

* fix: ignore error caused by Cloudflare HTML response

* add test

* Update src/tracing/errors.test.ts
Co-authored-by: default avatarZach Pomerantz <zzmp@uniswap.org>

* Update src/tracing/errors.ts
Co-authored-by: default avatarZach Pomerantz <zzmp@uniswap.org>

* Update src/tracing/errors.ts
Co-authored-by: default avatarZach Pomerantz <zzmp@uniswap.org>

* multiline
parent 4888fe23
...@@ -24,4 +24,9 @@ describe('filterKnownErrors', () => { ...@@ -24,4 +24,9 @@ describe('filterKnownErrors', () => {
const originalException = new Error('user rejected transaction') const originalException = new Error('user rejected transaction')
expect(filterKnownErrors(ERROR, { originalException })).toBe(null) expect(filterKnownErrors(ERROR, { originalException })).toBe(null)
}) })
it('filters invalid HTML response errors', () => {
const originalException = new SyntaxError("Unexpected token '<'")
expect(filterKnownErrors(ERROR, { originalException })).toBe(null)
})
}) })
...@@ -25,6 +25,13 @@ export const filterKnownErrors: Required<ClientOptions>['beforeSend'] = (event: ...@@ -25,6 +25,13 @@ export const filterKnownErrors: Required<ClientOptions>['beforeSend'] = (event:
// If the error is based on a user rejecting, it should not be considered an exception. // If the error is based on a user rejecting, it should not be considered an exception.
if (didUserReject(error)) return null 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.
*/
if (error.message.match(/Unexpected token '<'/)) return null
} }
return event return event
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment