-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch with a timeout everywhere #10101
Conversation
Builds ready [35f589d]
Page Load Metrics (534 ± 43 ms)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking as request changes, if only to see the comments.
I also wonder if we should up the 30 second; I wish we had metrics. We can probably start with 30 and if we get timeout reports, we can adjust.
@@ -227,7 +225,7 @@ export default class IncomingTransactionsController { | |||
if (fromBlock) { | |||
url += `&startBlock=${parseInt(fromBlock, 10)}` | |||
} | |||
const response = await fetch(url) | |||
const response = await fetchWithTimeout(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add a try/catch
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would we do in the catch
block in these cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log an error to Sentry so we can see if we're having transaction loading errors? Or would that not be helpful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These already get logged to Sentry, by virtue of being uncaught. Uncaught errors are all logged to Sentry.
Edit: Oh, actually, no these are caught. They're caught and logged to the console a few levels up in _getDataForUpdate
.
Though even still, I don't think this is necessarily something we want to log to Sentry anyway, because failures here aren't actionable for us (e.g. it's not a bug if someone disconnects from the internet)
@@ -29,8 +29,8 @@ const fetchWithCache = async ( | |||
return cachedResponse | |||
} | |||
fetchOptions.headers.set('Content-Type', 'application/json') | |||
const _fetch = timeout ? fetchWithTimeout({ timeout }) : window.fetch | |||
const response = await _fetch(url, { | |||
const fetchWithTimeout = getFetchWithTimeout(timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add a try/catch
here?
35f589d
to
e028f78
Compare
Builds ready [e028f78]
Page Load Metrics (596 ± 69 ms)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Uses
fetchWithTimeout
everywhere except indevelopment/
files.fetch-with-timeout.js
toshared/modules
getFetchWithTimeout
getFetchWithTimeout
default to 30 seconds (that's the longest timeout used in practice)