Commit acf97e04 authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

fix: filter WebAssembly compile errors (#6445)

* test

* fix: filter WebAssembly compilition errors

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

---------
parent 771618b1
......@@ -22,22 +22,22 @@ describe('filterKnownErrors', () => {
const originalException = new (class extends Error {
requestBody = JSON.stringify({ method: 'eth_blockNumber' })
})()
expect(filterKnownErrors(ERROR, { originalException })).toBe(null)
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
it('filters network change errors', () => {
const originalException = new Error('underlying network changed')
expect(filterKnownErrors(ERROR, { originalException })).toBe(null)
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
it('filters user rejected request errors', () => {
const originalException = new Error('user rejected transaction')
expect(filterKnownErrors(ERROR, { originalException })).toBe(null)
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
it('filters invalid HTML response errors', () => {
const originalException = new SyntaxError("Unexpected token '<'")
expect(filterKnownErrors(ERROR, { originalException })).toBe(null)
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
describe('chunk errors', () => {
......@@ -152,14 +152,21 @@ describe('filterKnownErrors', () => {
const originalException = new Error(
"Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: \"script-src 'self' https://www.google-analytics.com https://www.googletagmanager.com 'unsafe-inlin..."
)
expect(filterKnownErrors(ERROR, { originalException })).toBe(null)
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
it('filters CSP unsafe-eval compile/instatiate errors', () => {
const originalException = new Error(
"Refused to compile or instantiate WebAssembly module because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: \"script-src 'self' https://www.google-a..."
)
expect(filterKnownErrors(ERROR, { originalException })).toBe(null)
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
it('filters WebAssembly compilation errors', () => {
const originalException = new Error(
'Aborted(CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder). Build with -sASSERTIONS for more info.'
)
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
})
})
......@@ -93,6 +93,12 @@ export const filterKnownErrors: Required<ClientOptions>['beforeSend'] = (event:
if (error.message.match(/'unsafe-eval'.*content security policy/i)) {
return null
}
// WebAssembly compilation fails because we do not allow 'unsafe-eval' in our CSP.
// Any thrown errors are due to 3P extensions/applications, so we do not need to handle them.
if (error.message.match(/WebAssembly.instantiate\(\): Wasm code generation disallowed by embedder/)) {
return null
}
}
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