Make DevTools Websocket retry delay configurable (#20107)
This commit is contained in:
parent
779a472b09
commit
b6a750be3c
|
@ -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`
|
||||
|
|
|
@ -26,6 +26,7 @@ type ConnectOptions = {
|
|||
port?: number,
|
||||
useHttps?: boolean,
|
||||
resolveRNStyle?: ResolveNativeStyle,
|
||||
retryConnectionDelay?: number,
|
||||
isAppActive?: () => boolean,
|
||||
websocket?: ?WebSocket,
|
||||
...
|
||||
|
@ -60,6 +61,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
|
|||
port = 8097,
|
||||
websocket,
|
||||
resolveRNStyle = null,
|
||||
retryConnectionDelay = 2000,
|
||||
isAppActive = () => true,
|
||||
} = options || {};
|
||||
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue