Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3753472
D8679.id29444.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D8679.id29444.diff
View Options
diff --git a/native/components/feature-flags-provider.react.js b/native/components/feature-flags-provider.react.js
--- a/native/components/feature-flags-provider.react.js
+++ b/native/components/feature-flags-provider.react.js
@@ -5,6 +5,7 @@
import { Platform } from 'react-native';
import { fetchFeatureFlags } from 'lib/utils/feature-flags-utils.js';
+import sleep from 'lib/utils/sleep.js';
import { useIsCurrentUserStaff } from 'native/utils/staff-utils.js';
import { codeVersion } from '../redux/persist.js';
@@ -64,11 +65,12 @@
React.useEffect(() => {
(async () => {
try {
- const config = await fetchFeatureFlags(
- Platform.OS,
- isStaff,
- codeVersion,
+ const config = await tryMultipleTimes(
+ () => fetchFeatureFlags(Platform.OS, isStaff, codeVersion),
+ 3,
+ 5000,
);
+
const configuration = {};
for (const feature of config.enabledFeatures) {
configuration[feature] = true;
@@ -94,4 +96,24 @@
);
}
+async function tryMultipleTimes<T>(
+ f: () => Promise<T>,
+ numberOfTries: number,
+ delay: number,
+): Promise<T> {
+ let lastError;
+ while (numberOfTries > 0) {
+ try {
+ return await f();
+ } catch (e) {
+ --numberOfTries;
+ lastError = e;
+ if (numberOfTries > 0) {
+ await sleep(delay);
+ }
+ }
+ }
+ throw lastError;
+}
+
export { FeatureFlagsContext, FeatureFlagsProvider, featureFlagsStorageKey };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 11, 2:13 AM (19 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2858330
Default Alt Text
D8679.id29444.diff (1 KB)
Attached To
Mode
D8679: [native] Retry feature flags call
Attached
Detach File
Event Timeline
Log In to Comment