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:
parent
3e5c0bddd7
commit
ffdd311be9
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user