diff --git a/desktop/flipper-ui/package.json b/desktop/flipper-ui/package.json index 32961c9d698..448d079df81 100644 --- a/desktop/flipper-ui/package.json +++ b/desktop/flipper-ui/package.json @@ -72,7 +72,8 @@ "metro-runtime": "^0.70.2", "pretty-format": "^29.7.0", "react-refresh": "^0.14.0", - "redux-mock-store": "^1.0.1" + "redux-mock-store": "^1.0.1", + "ts-retry-promise": "^0.8.0" }, "peerDependencies": {}, "scripts": { diff --git a/desktop/flipper-ui/src/Client.tsx b/desktop/flipper-ui/src/Client.tsx index 366d1376333..d895829ca93 100644 --- a/desktop/flipper-ui/src/Client.tsx +++ b/desktop/flipper-ui/src/Client.tsx @@ -45,6 +45,7 @@ import {EventEmitter} from 'eventemitter3'; import {createServerAddOnControls} from './utils/createServerAddOnControls'; import isProduction from './utils/isProduction'; import {freeze} from 'immer'; +import {retry} from 'ts-retry-promise'; type Plugins = Set; type PluginsArr = Array; @@ -236,10 +237,26 @@ export default class Client extends EventEmitter { // get the supported plugins async loadPlugins(phase: 'init' | 'refresh'): Promise> { try { - const response = await timeout( - 30 * 1000, - this.rawCall<{plugins: Plugins}>('getPlugins', false), - 'Fetch plugin timeout. Unresponsive client?', + const response = await retry( + () => + //shortish timeout for each individual request + timeout( + 5 * 1000, + this.rawCall<{plugins: Plugins}>('getPlugins', false), + 'Fetch plugin timeout. Unresponsive client?', + ), + { + retries: 5, + delay: 1000, + backoff: 'LINEAR', + logger: (msg) => + this.flipperServer.exec( + 'log-connectivity-event', + 'warning', + this.query, + `Attempt to fetch plugins failed for phase ${phase}, Error: ${msg}`, + ), + }, ); this.plugins = new Set(response.plugins ?? []); console.info( diff --git a/desktop/yarn.lock b/desktop/yarn.lock index e66c982b150..62f618e0a9a 100644 --- a/desktop/yarn.lock +++ b/desktop/yarn.lock @@ -12401,6 +12401,11 @@ ts-node@^10.9.1: v8-compile-cache-lib "^3.0.1" yn "3.1.1" +ts-retry-promise@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/ts-retry-promise/-/ts-retry-promise-0.8.0.tgz#0a0c57b510827d5630da4b0c47f36b55b83a49e3" + integrity sha512-elI/GkojPANBikPaMWQnk4T/bOJ6tq/hqXyQRmhfC9PAD6MoHmXIXK7KilJrlpx47VAKCGcmBrTeK5dHk6YAYg== + tsconfig-paths@^3.15.0: version "3.15.0" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz#5299ec605e55b1abb23ec939ef15edaf483070d4"