-
Notifications
You must be signed in to change notification settings - Fork 273
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/superset/superset-ui/f9jfvw1pg |
28915a2
to
dfb2ee8
Compare
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.
wow this looks pretty sweet! left a couple comments but overall LGTM.
happy someone already wrote the fetch-retry
package 😅
import { CallApi } from '../types'; | ||
import { CACHE_AVAILABLE, CACHE_KEY, HTTP_STATUS_NOT_MODIFIED, HTTP_STATUS_OK } from '../constants'; | ||
|
||
const RETRY_COUNT = 3; | ||
const RETRY_DELAY_MS = 1000; | ||
const RETRY_ON_HTTP_STATUS_CODES = [503]; |
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 you think we should make this configurable? like make this the default but override-able?
we could do that for all of the constants actually. no reason not to expose them for more granular customization?
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.
That's a good call, I'll move it into the SupersetClient class.
@@ -437,7 +439,7 @@ describe('callApi()', () => { | |||
}); | |||
}); | |||
|
|||
it('rejects if the request throws', () => { | |||
it('rejects after retrying thrice if the request throws', () => { |
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.
could update the tests to match the retry config variables specified if we expose them
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.
this is pretty awesome tho that the throwing is delayed
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.
updated
import { CallApi } from '../types'; | ||
import { CACHE_AVAILABLE, CACHE_KEY, HTTP_STATUS_NOT_MODIFIED, HTTP_STATUS_OK } from '../constants'; | ||
|
||
const RETRY_COUNT = 3; |
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.
since this is a pretty big change, I wonder if we should make this 2
by default for a total of 3 requests? not really sure what's standard.
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.
3 is the default for the package and is a standard i've seen before. if we make this configurable i think it's fine to default it though
Codecov Report
@@ Coverage Diff @@
## master #384 +/- ##
==========================================
+ Coverage 26.35% 26.40% +0.05%
==========================================
Files 192 192
Lines 5256 5260 +4
Branches 459 460 +1
==========================================
+ Hits 1385 1389 +4
Misses 3842 3842
Partials 29 29
Continue to review full report at Codecov.
|
@@ -16,6 +21,12 @@ export default function callApi({ | |||
stringify = true, | |||
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.
Can we add the retry options to callApi
arguments, too, in case people want to override the defaults?
I'd also argue it's probably safer to make this an opt-in rather than opt-out. Can add an API to superset-ui/connection
to change the defaults.
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.
I've added the retry options to the SupersetClient config. However, I think it's fair to make this opt out. I can add a comment in incubator-superset that this was added, but I think the common path should include QOL features like automatic retried on network issues
dfb2ee8
to
d5e6de2
Compare
@@ -40,6 +44,7 @@ export default class SupersetClientClass { | |||
this.credentials = credentials; | |||
this.csrfToken = csrfToken; | |||
this.csrfPromise = undefined; | |||
this.fetchRetryOptions = fetchRetryOptions; |
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.
Maybe this.fetchRetryOptions = { ...DEFAULT_FETCH_RETRY_OPTIONS, ...fetchRetryOptions }
and fetchRetryOptions = {}
in L33
in case people only want to override one of the options.
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.
good call
d5e6de2
to
4193359
Compare
🏆 Enhancements
Adds the
fetch-retry
package to automatically retry any requests that fail due to network issues or 503 errors. This seems like a pretty safe approach to apply to all requests, but would appreciate feedback, especially if you think it's likely to break something.Test Plan:
add/update unit tests
to: @kristw @williaster @ktmud @rusackas