From ffdd311be95ae2afde13621b0faa0c2337fe5094 Mon Sep 17 00:00:00 2001 From: Vignesh Mohankumar Date: Fri, 21 Apr 2023 16:34:08 -0400 Subject: [PATCH] fix: handle other types of chunk error codes (#6423) * fix: handle other types of chunk error codes * lint * change regex * letters only --- src/tracing/errors.test.ts | 26 ++++++++++++++++++++++++++ src/tracing/errors.ts | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/tracing/errors.test.ts b/src/tracing/errors.test.ts index d37cd60223..52e56fc6fd 100644 --- a/src/tracing/errors.test.ts +++ b/src/tracing/errors.test.ts @@ -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([ { diff --git a/src/tracing/errors.ts b/src/tracing/errors.ts index 4ee58efd2c..e122e0efb1 100644 --- a/src/tracing/errors.ts +++ b/src/tracing/errors.ts @@ -67,7 +67,7 @@ export const filterKnownErrors: Required['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 }