Skip to content

Commit

Permalink
Make DevTools Websocket retry delay configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Oct 27, 2020
1 parent 4e5d7fa commit 09fe7ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/react-devtools-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The `config` object may contain:
* `useHttps: boolean` (defaults to `false`) - Websocked should use a secure protocol (wss).
* `websocket: Websocket` - Custom websocket to use. Overrides `host` and `port` settings if provided.
* `resolveRNStyle: (style: number) => ?Object` - Used by the React Native style plug-in.
* `retryConnectionDelay: number` (defaults to `2000`) - Milliseconds delay to wait between retrying a failed Websocket connection.
* `isAppActive: () => boolean` - If provided, DevTools will poll this method and wait until it returns true before connecting to React.

## `react-devtools-core/standalone`
Expand Down
7 changes: 6 additions & 1 deletion packages/react-devtools-core/src/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type ConnectOptions = {
port?: number,
useHttps?: boolean,
resolveRNStyle?: ResolveNativeStyle,
retryConnectionDelay?: number,
isAppActive?: () => boolean,
websocket?: ?WebSocket,
...
Expand Down Expand Up @@ -60,6 +61,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
port = 8097,
websocket,
resolveRNStyle = null,
retryConnectionDelay = 2000,
isAppActive = () => true,
} = options || {};

Expand All @@ -69,7 +71,10 @@ export function connectToDevTools(options: ?ConnectOptions) {
function scheduleRetry() {
if (retryTimeoutID === null) {
// Two seconds because RN had issues with quick retries.
retryTimeoutID = setTimeout(() => connectToDevTools(options), 2000);
retryTimeoutID = setTimeout(
() => connectToDevTools(options),
retryConnectionDelay,
);
}
}

Expand Down

0 comments on commit 09fe7ad

Please sign in to comment.