Skip to content

Commit 09fe7ad

Browse files
author
Brian Vaughn
committed
Make DevTools Websocket retry delay configurable
1 parent 4e5d7fa commit 09fe7ad

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/react-devtools-core/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The `config` object may contain:
2424
* `useHttps: boolean` (defaults to `false`) - Websocked should use a secure protocol (wss).
2525
* `websocket: Websocket` - Custom websocket to use. Overrides `host` and `port` settings if provided.
2626
* `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.
2728
* `isAppActive: () => boolean` - If provided, DevTools will poll this method and wait until it returns true before connecting to React.
2829

2930
## `react-devtools-core/standalone`

packages/react-devtools-core/src/backend.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type ConnectOptions = {
2626
port?: number,
2727
useHttps?: boolean,
2828
resolveRNStyle?: ResolveNativeStyle,
29+
retryConnectionDelay?: number,
2930
isAppActive?: () => boolean,
3031
websocket?: ?WebSocket,
3132
...
@@ -60,6 +61,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
6061
port = 8097,
6162
websocket,
6263
resolveRNStyle = null,
64+
retryConnectionDelay = 2000,
6365
isAppActive = () => true,
6466
} = options || {};
6567

@@ -69,7 +71,10 @@ export function connectToDevTools(options: ?ConnectOptions) {
6971
function scheduleRetry() {
7072
if (retryTimeoutID === null) {
7173
// Two seconds because RN had issues with quick retries.
72-
retryTimeoutID = setTimeout(() => connectToDevTools(options), 2000);
74+
retryTimeoutID = setTimeout(
75+
() => connectToDevTools(options),
76+
retryConnectionDelay,
77+
);
7378
}
7479
}
7580

0 commit comments

Comments
 (0)