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

fix: handle other types of chunk error codes (#6423)

* fix: handle other types of chunk error codes

* lint

* change regex

* letters only
parent 3e5c0bdd
...@@ -58,6 +58,32 @@ describe('filterKnownErrors', () => { ...@@ -58,6 +58,32 @@ describe('filterKnownErrors', () => {
expect(filterKnownErrors(ERROR, { originalException })).toBeNull() expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
}) })
it('filters 499 error coded chunk timeout', () => {
jest.spyOn(window.performance, 'getEntriesByType').mockReturnValue([
{
name: 'https://app.uniswap.org/static/js/20.d55382e0.chunk.js',
responseStatus: 499,
} as PerformanceEntry,
])
const originalException = new Error(
'Loading chunk 20 failed. (timeout: https://app.uniswap.org/static/js/20.d55382e0.chunk.js)'
)
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
it('filters 499 error coded chunk missing', () => {
jest.spyOn(window.performance, 'getEntriesByType').mockReturnValue([
{
name: 'https://app.uniswap.org/static/js/20.d55382e0.chunk.js',
responseStatus: 499,
} as PerformanceEntry,
])
const originalException = new Error(
'Loading chunk 20 failed. (missing: https://app.uniswap.org/static/js/20.d55382e0.chunk.js)'
)
expect(filterKnownErrors(ERROR, { originalException })).toBeNull()
})
it('filters 499 error coded CSS chunk error', () => { it('filters 499 error coded CSS chunk error', () => {
jest.spyOn(window.performance, 'getEntriesByType').mockReturnValue([ jest.spyOn(window.performance, 'getEntriesByType').mockReturnValue([
{ {
......
...@@ -67,7 +67,7 @@ export const filterKnownErrors: Required<ClientOptions>['beforeSend'] = (event: ...@@ -67,7 +67,7 @@ export const filterKnownErrors: Required<ClientOptions>['beforeSend'] = (event:
* CF claims that some number of these is expected, and that they should be ignored. * CF claims that some number of these is expected, and that they should be ignored.
* See https://groups.google.com/a/uniswap.org/g/cloudflare-eng/c/t3xvAiJFujY. * See https://groups.google.com/a/uniswap.org/g/cloudflare-eng/c/t3xvAiJFujY.
*/ */
if (error.message.match(/Loading chunk \d+ failed\. \(error: .+\.chunk\.js\)/)) { if (error.message.match(/Loading chunk \d+ failed\. \(([a-zA-Z]+): .+\.chunk\.js\)/)) {
const asset = error.message.match(/https?:\/\/.+?\.chunk\.js/)?.[0] const asset = error.message.match(/https?:\/\/.+?\.chunk\.js/)?.[0]
if (shouldFilterChunkError(asset)) return null if (shouldFilterChunkError(asset)) return null
} }
......
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