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

* fix: handle other types of chunk error codes

* lint

* change regex

* letters only
This commit is contained in:
Vignesh Mohankumar 2023-04-21 16:34:08 -04:00 committed by GitHub
parent 3e5c0bddd7
commit ffdd311be9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

@ -58,6 +58,32 @@ describe('filterKnownErrors', () => {
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', () => {
jest.spyOn(window.performance, 'getEntriesByType').mockReturnValue([
{

@ -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.
* 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]
if (shouldFilterChunkError(asset)) return null
}