Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
916ebef4
Unverified
Commit
916ebef4
authored
Apr 21, 2023
by
Vignesh Mohankumar
Committed by
GitHub
Apr 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: filter CSS related 499 chunk errors (#6417)
* add in css errors * rm console * change code
parent
aa77a7a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
12 deletions
+42
-12
errors.test.ts
src/tracing/errors.test.ts
+23
-1
errors.ts
src/tracing/errors.ts
+19
-11
No files found.
src/tracing/errors.test.ts
View file @
916ebef4
...
...
@@ -58,11 +58,22 @@ describe('filterKnownErrors', () => {
expect
(
filterKnownErrors
(
ERROR
,
{
originalException
})).
toBeNull
()
})
it
(
'
filters 499 error coded CSS chunk error
'
,
()
=>
{
jest
.
spyOn
(
window
.
performance
,
'
getEntriesByType
'
).
mockReturnValue
([
{
name
:
'
https://app.uniswap.org/static/css/12.d5b3cfe3.chunk.css
'
,
responseStatus
:
499
,
}
as
PerformanceEntry
,
])
const
originalException
=
new
Error
(
'
Loading CSS chunk 12 failed. (./static/css/12.d5b3cfe3.chunk.css)
'
)
expect
(
filterKnownErrors
(
ERROR
,
{
originalException
})).
toBeNull
()
})
it
(
'
keeps error when status is different than 499
'
,
()
=>
{
jest
.
spyOn
(
window
.
performance
,
'
getEntriesByType
'
).
mockReturnValue
([
{
name
:
'
https://app.uniswap.org/static/js/20.d55382e0.chunk.js
'
,
responseStatus
:
2
00
,
responseStatus
:
4
00
,
}
as
PerformanceEntry
,
])
const
originalException
=
new
Error
(
...
...
@@ -71,6 +82,17 @@ describe('filterKnownErrors', () => {
expect
(
filterKnownErrors
(
ERROR
,
{
originalException
})).
not
.
toBeNull
()
})
it
(
'
keeps CSS error when status is different than 499
'
,
()
=>
{
jest
.
spyOn
(
window
.
performance
,
'
getEntriesByType
'
).
mockReturnValue
([
{
name
:
'
https://app.uniswap.org/static/css/12.d5b3cfe3.chunk.css
'
,
responseStatus
:
400
,
}
as
PerformanceEntry
,
])
const
originalException
=
new
Error
(
'
Loading CSS chunk 12 failed. (./static/css/12.d5b3cfe3.chunk.css)
'
)
expect
(
filterKnownErrors
(
ERROR
,
{
originalException
})).
not
.
toBeNull
()
})
it
(
'
filters out error when resource is missing
'
,
()
=>
{
jest
.
spyOn
(
window
.
performance
,
'
getEntriesByType
'
).
mockReturnValue
([])
const
originalException
=
new
Error
(
...
...
src/tracing/errors.ts
View file @
916ebef4
...
...
@@ -29,6 +29,19 @@ export function beforeSend(event: ErrorEvent, hint: EventHint) {
return
filterKnownErrors
(
event
,
hint
)
}
function
shouldFilterChunkError
(
asset
?:
string
)
{
const
entries
=
[...(
performance
?.
getEntriesByType
(
'
resource
'
)
??
[])]
const
resource
=
entries
?.
find
(({
name
})
=>
name
===
asset
)
const
status
=
resource
?.
responseStatus
/*
* If the status if 499, then we ignore.
* If there's no status (meaning the browser doesn't support `responseStatus`) then we also ignore.
* These errors are likely also 499 errors, and we can catch any spikes in non-499 chunk errors via other browsers.
*/
return
!
status
||
status
===
499
}
/**
* Filters known (ignorable) errors out before sending them to Sentry.
* Intended as a {@link ClientOptions.beforeSend} callback. Returning null filters the error from Sentry.
...
...
@@ -56,18 +69,13 @@ export const filterKnownErrors: Required<ClientOptions>['beforeSend'] = (event:
*/
if
(
error
.
message
.
match
(
/Loading chunk
\d
+ failed
\.
\(
error: .+
\.
chunk
\.
js
\)
/
))
{
const
asset
=
error
.
message
.
match
(
/https
?
:
\/\/
.+
?\.
chunk
\.
js/
)?.[
0
]
const
entries
=
[...(
performance
?.
getEntriesByType
(
'
resource
'
)
??
[])]
const
resource
=
entries
?.
find
(({
name
})
=>
name
===
asset
)
const
status
=
resource
?.
responseStatus
if
(
shouldFilterChunkError
(
asset
))
return
null
}
/*
* If the status if 499, then we ignore.
* If there's no status (meaning the browser doesn't support `responseStatus`) then we also ignore.
* These errors are likely also 499 errors, and we can catch any spikes in non-499 chunk errors via other browsers.
*/
if
(
!
status
||
status
===
499
)
{
return
null
}
if
(
error
.
message
.
match
(
/Loading CSS chunk
\d
+ failed
\.
\(
.+
\.
chunk
\.
css
\)
/
))
{
const
relativePath
=
error
.
message
.
match
(
/
\/
static
\/
css
\/
.*
\.
chunk
\.
css/
)?.[
0
]
const
asset
=
`https://app.uniswap.org
${
relativePath
}
`
if
(
shouldFilterChunkError
(
asset
))
return
null
}
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment