Page MenuHomePhabricator

D8679.id29444.diff
No OneTemporary

D8679.id29444.diff

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

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)

Event Timeline