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
fbc55db9
Unverified
Commit
fbc55db9
authored
May 21, 2023
by
Vignesh Mohankumar
Committed by
GitHub
May 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: remove chunkResponseStatus tag (#6586)
* chore: remove chunkResponseStatus tag * lint
parent
835c62ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
87 deletions
+1
-87
errors.test.ts
src/tracing/errors.test.ts
+1
-53
errors.ts
src/tracing/errors.ts
+0
-34
No files found.
src/tracing/errors.test.ts
View file @
fbc55db9
import
{
ErrorEvent
,
Event
}
from
'
@sentry/types
'
import
{
ErrorEvent
}
from
'
@sentry/types
'
import
{
beforeSend
}
from
'
./errors
'
import
{
beforeSend
}
from
'
./errors
'
...
@@ -45,58 +45,6 @@ describe('beforeSend', () => {
...
@@ -45,58 +45,6 @@ describe('beforeSend', () => {
})
})
})
})
describe
(
'
chunkResponseStatus
'
,
()
=>
{
afterEach
(()
=>
{
jest
.
restoreAllMocks
()
})
it
(
'
handles when matching JS file not found
'
,
()
=>
{
jest
.
spyOn
(
window
.
performance
,
'
getEntriesByType
'
).
mockReturnValue
([])
const
originalException
=
new
Error
(
'
Loading chunk 20 failed. (error: https://app.uniswap.org/static/js/20.d55382e0.chunk.js)
'
)
expect
((
beforeSend
(
ERROR
,
{
originalException
})
as
Event
).
tags
).
toBeUndefined
()
})
it
(
'
handles when matching CSS file not found
'
,
()
=>
{
jest
.
spyOn
(
window
.
performance
,
'
getEntriesByType
'
).
mockReturnValue
([])
const
originalException
=
new
Error
(
'
Loading chunk 20 failed. (error: https://app.uniswap.org/static/js/20.d55382e0.chunk.js)
'
)
expect
((
beforeSend
(
ERROR
,
{
originalException
})
as
Event
).
tags
).
toBeUndefined
()
})
it
(
'
handles when performance is undefined
'
,
()
=>
{
window
.
performance
=
undefined
as
any
const
originalException
=
new
Error
(
'
Loading CSS chunk 12 failed. (./static/css/12.d5b3cfe3.chunk.css)
'
)
expect
((
beforeSend
(
ERROR
,
{
originalException
})
as
Event
).
tags
).
toBeUndefined
()
})
it
(
'
adds status for a matching JS file
'
,
()
=>
{
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. (error: https://app.uniswap.org/static/js/20.d55382e0.chunk.js)
'
)
expect
((
beforeSend
(
ERROR
,
{
originalException
})
as
Event
).
tags
?.
chunkResponseStatus
).
toBe
(
499
)
})
it
(
'
adds status for a matching CSS file
'
,
()
=>
{
jest
.
spyOn
(
window
.
performance
,
'
getEntriesByType
'
).
mockReturnValue
([
{
name
:
'
https://app.uniswap.org/static/css/12.d5b3cfe3.chunk.css
'
,
responseStatus
:
200
,
}
as
PerformanceEntry
,
])
const
originalException
=
new
Error
(
'
Loading CSS chunk 12 failed. (./static/css/12.d5b3cfe3.chunk.css)
'
)
expect
((
beforeSend
(
ERROR
,
{
originalException
})
as
Event
).
tags
?.
chunkResponseStatus
).
toBe
(
200
)
})
})
it
(
'
propagates an error
'
,
()
=>
{
it
(
'
propagates an error
'
,
()
=>
{
expect
(
beforeSend
(
ERROR
,
{})).
toBe
(
ERROR
)
expect
(
beforeSend
(
ERROR
,
{})).
toBe
(
ERROR
)
})
})
...
...
src/tracing/errors.ts
View file @
fbc55db9
...
@@ -18,7 +18,6 @@ export const beforeSend: Required<ClientOptions>['beforeSend'] = (event: ErrorEv
...
@@ -18,7 +18,6 @@ export const beforeSend: Required<ClientOptions>['beforeSend'] = (event: ErrorEv
}
}
updateRequestUrl
(
event
)
updateRequestUrl
(
event
)
addChunkResponseStatusTag
(
event
,
hint
)
return
event
return
event
}
}
...
@@ -42,39 +41,6 @@ function updateRequestUrl(event: ErrorEvent) {
...
@@ -42,39 +41,6 @@ function updateRequestUrl(event: ErrorEvent) {
}
}
}
}
// If a request fails due to a chunk error, this looks for that asset in the performance entries.
// If found, it adds a tag to the event with the response status of the chunk request.
function
addChunkResponseStatusTag
(
event
:
ErrorEvent
,
hint
:
EventHint
)
{
const
error
=
hint
.
originalException
if
(
error
instanceof
Error
)
{
let
asset
:
string
|
undefined
if
(
error
.
message
.
match
(
/Loading chunk
\d
+ failed
\.
\(([
a-zA-Z
]
+
)
: .+
\.
chunk
\.
js
\)
/
))
{
asset
=
error
.
message
.
match
(
/https
?
:
\/\/
.+
?\.
chunk
\.
js/
)?.[
0
]
}
if
(
error
.
message
.
match
(
/Loading CSS chunk
\d
+ failed
\.
\(
.+
\.
chunk
\.
css
\)
/
))
{
const
relativePath
=
error
.
message
.
match
(
/
\/
static
\/
css
\/
.*
\.
chunk
\.
css/
)?.[
0
]
asset
=
`
${
window
.
origin
}${
relativePath
}
`
}
if
(
asset
)
{
const
status
=
getChunkResponseStatus
(
asset
)
if
(
status
)
{
if
(
!
event
.
tags
)
{
event
.
tags
=
{}
}
event
.
tags
.
chunkResponseStatus
=
status
}
}
}
}
function
getChunkResponseStatus
(
asset
?:
string
):
number
|
undefined
{
const
entries
=
[...(
performance
?.
getEntriesByType
(
'
resource
'
)
??
[])]
const
resource
=
entries
?.
find
(({
name
})
=>
name
===
asset
)
return
resource
?.
responseStatus
}
function
shouldRejectError
(
error
:
EventHint
[
'
originalException
'
])
{
function
shouldRejectError
(
error
:
EventHint
[
'
originalException
'
])
{
if
(
error
instanceof
Error
)
{
if
(
error
instanceof
Error
)
{
// ethers aggressively polls for block number, and it sometimes fails (whether spuriously or through rate-limiting).
// ethers aggressively polls for block number, and it sometimes fails (whether spuriously or through rate-limiting).
...
...
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