Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
7b0846f1
Unverified
Commit
7b0846f1
authored
May 20, 2020
by
Robert Knight
Committed by
GitHub
May 20, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2164 from hypothesis/sentry-fetch-errors
Make fetch exceptions consistent and filter them from Sentry
parents
61f44ff4
299106f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
1 deletion
+24
-1
api.js
src/sidebar/services/api.js
+6
-0
api-test.js
src/sidebar/services/test/api-test.js
+2
-1
sentry.js
src/sidebar/util/sentry.js
+2
-0
sentry-test.js
src/sidebar/util/test/sentry-test.js
+14
-0
No files found.
src/sidebar/services/api.js
View file @
7b0846f1
...
...
@@ -136,6 +136,12 @@ function createAPICall(
body
:
data
?
JSON
.
stringify
(
stripInternalProperties
(
data
))
:
null
,
headers
,
method
:
descriptor
.
method
,
}).
catch
(()
=>
{
// Re-throw Fetch errors such that they all "look the same" (different
// browsers throw different Errors on Fetch failure). This allows
// Fetch failures to be either handled in particular ways higher up
// or for them to be ignored in error reporting (see `sentry` config).
throw
new
Error
(
`Fetch operation failed for URL '
${
url
}
'`
);
});
})
.
then
(
response
=>
{
...
...
src/sidebar/services/test/api-test.js
View file @
7b0846f1
...
...
@@ -175,7 +175,8 @@ describe('sidebar.services.api', function () {
// Network error
status
:
null
,
body
:
'Service unreachable.'
,
expectedMessage
:
'Service unreachable.'
,
expectedMessage
:
"Fetch operation failed for URL 'https://example.com/api/profile'"
,
},
{
// Request failed with an error given in the JSON body
...
...
src/sidebar/util/sentry.js
View file @
7b0846f1
...
...
@@ -51,6 +51,8 @@ export function init(config) {
Sentry
.
init
({
dsn
:
config
.
dsn
,
environment
:
config
.
environment
,
// Do not log Fetch failures to avoid inundating with unhandled fetch exceptions
ignoreErrors
:
[
'Fetch operation failed'
],
release
:
'__VERSION__'
,
// replaced by versionify
whitelistUrls
,
...
...
src/sidebar/util/test/sentry-test.js
View file @
7b0846f1
...
...
@@ -75,6 +75,20 @@ describe('sidebar/util/sentry', () => {
);
});
it
(
'configures Sentry to ignore Errors with matching the text "Fetch operation failed"'
,
()
=>
{
sentry
.
init
({
dsn
:
'test-dsn'
,
environment
:
'dev'
,
});
assert
.
calledWith
(
fakeSentry
.
init
,
sinon
.
match
({
ignoreErrors
:
[
'Fetch operation failed'
],
})
);
});
it
(
'disables the URL whitelist if `document.currentScript` is inaccessible'
,
()
=>
{
fakeDocumentCurrentScript
.
get
(()
=>
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