@samitouri / QOS-React / commits / b6a750be3c

Make DevTools Websocket retry delay configurable (#20107)

Brian Vaughn committed Oct 28, 2020 at 22:08 UTC b6a750be3ca0fc4126ef018e205c951b890c1881
2 files changed +7 -1
packages/react-devtools-core/README.md
+1
@@ -24,6 +24,7 @@ The `config` object may contain:
24 * `useHttps: boolean` (defaults to `false`) - Websocked should use a secure protocol (wss).
25 * `websocket: Websocket` - Custom websocket to use. Overrides `host` and `port` settings if provided.
26 * `resolveRNStyle: (style: number) => ?Object` - Used by the React Native style plug-in.
27 +* `retryConnectionDelay: number` (defaults to `2000`) - Milliseconds delay to wait between retrying a failed Websocket connection.
28 * `isAppActive: () => boolean` - If provided, DevTools will poll this method and wait until it returns true before connecting to React.
29
30 ## `react-devtools-core/standalone`
packages/react-devtools-core/src/backend.js
+6 -1
@@ -26,6 +26,7 @@ type ConnectOptions = {
26 port?: number,
27 useHttps?: boolean,
28 resolveRNStyle?: ResolveNativeStyle,
29 + retryConnectionDelay?: number,
30 isAppActive?: () => boolean,
31 websocket?: ?WebSocket,
32 ...
@@ -60,6 +61,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
61 port = 8097,
62 websocket,
63 resolveRNStyle = null,
64 + retryConnectionDelay = 2000,
65 isAppActive = () => true,
66 } = options || {};
67
@@ -69,7 +71,10 @@ export function connectToDevTools(options: ?ConnectOptions) {
71 function scheduleRetry() {
72 if (retryTimeoutID === null) {
73 // Two seconds because RN had issues with quick retries.
72 - retryTimeoutID = setTimeout(() => connectToDevTools(options), 2000);
74 + retryTimeoutID = setTimeout(
75 + () => connectToDevTools(options),
76 + retryConnectionDelay,
77 + );
78 }
79 }
80