Skip to content
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

Merged
merged 3 commits into from
Jan 19, 2021
Merged

Conversation

rekmarks
Copy link
Member

@rekmarks rekmarks commented Dec 17, 2020

Uses fetchWithTimeout everywhere except in development/ files.

  • Move fetch-with-timeout.js to shared/modules
  • Memoize getFetchWithTimeout
  • Change getFetchWithTimeout default to 30 seconds (that's the longest timeout used in practice)
  • Require a timeout to be specified

@rekmarks rekmarks requested a review from a team as a code owner December 17, 2020 19:13
@rekmarks rekmarks requested a review from danjm December 17, 2020 19:13
@metamaskbot
Copy link
Collaborator

Builds ready [35f589d]
Page Load Metrics (534 ± 43 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint316748105
domContentLoaded3166425328943
load3176435348943
domInteractive3166425328943

NiranjanaBinoy
NiranjanaBinoy previously approved these changes Dec 17, 2020
Copy link
Contributor

@NiranjanaBinoy NiranjanaBinoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@darkwing darkwing left a 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)
Copy link
Contributor

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?

Copy link
Member

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?

Copy link
Contributor

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?

Copy link
Member

@Gudahtt Gudahtt Jan 5, 2021

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)

ui/app/ducks/gas/gas.duck.js Show resolved Hide resolved
@@ -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)
Copy link
Contributor

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?

@metamaskbot
Copy link
Collaborator

Builds ready [e028f78]
Page Load Metrics (596 ± 69 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint318251147
domContentLoaded32979959514469
load33080059614469
domInteractive32979959514469

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@darkwing darkwing self-requested a review January 19, 2021 14:41
@rekmarks rekmarks merged commit 7159dd6 into develop Jan 19, 2021
@rekmarks rekmarks deleted the fetch-with-timeout-everywhere branch January 19, 2021 16:41
@github-actions github-actions bot locked and limited conversation to collaborators Jan 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants