fix(remote): always apply socket options

Previously, user-specified socket options were applied only if a port was specified. Now, they are always applied. Furthermore, the autoReconnect option from default socket options is always included now.
This commit is contained in:
Joni Savolainen 2023-09-24 15:12:00 +03:00
parent 9695e499f2
commit 3800a2ea6d
2 changed files with 9 additions and 10 deletions

View File

@ -137,9 +137,9 @@ For React Native you can use [remotedev-rn-debugger](https://github.com/jhen0409
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | _String_ representing the instance name to be shown on the remote monitor. |
| `realtime` | _Boolean_ specifies whether to allow remote monitoring. By default is `process.env.NODE_ENV === 'development'`. |
| `hostname` | _String_ used to specify host for [@redux-devtools/cli](https://github.com/reduxjs/redux-devtools/tree/main/packages/redux-devtools-cli). If `port` is specified, default value is `localhost`. |
| `port` | _Number_ used to specify host's port for [@redux-devtools/cli](https://github.com/reduxjs/redux-devtools/tree/main/packages/redux-devtools-cli). |
| `secure` | _Boolean_ specifies whether to use `https` protocol for [@redux-devtools/cli](https://github.com/reduxjs/redux-devtools/tree/main/packages/redux-devtools-cli). |
| `hostname` | _String_ used to specify host for [@redux-devtools/cli](https://github.com/reduxjs/redux-devtools/tree/main/packages/redux-devtools-cli). The default value is `localhost`. |
| `port` | _Number_ used to specify host's port for [@redux-devtools/cli](https://github.com/reduxjs/redux-devtools/tree/main/packages/redux-devtools-cli). The default value is `8000`. |
| `secure` | _Boolean_ specifies whether to use `https` protocol for [@redux-devtools/cli](https://github.com/reduxjs/redux-devtools/tree/main/packages/redux-devtools-cli). The default value is `false`. |
| `maxAge` | _Number_ of maximum allowed actions to be stored on the history tree, the oldest actions are removed once maxAge is reached. Default is `30`. |
| `actionsDenylist` | _array_ of actions to be hidden in DevTools. Overwrites corresponding global setting in the options page. See the example bellow. |
| `actionsAllowlist` | _array_ of actions to be shown. All other actions will be hidden in DevTools. |

View File

@ -357,13 +357,12 @@ class DevToolsEnhancer<S, A extends Action<unknown>> {
whitelist ??
options.actionsWhitelist,
});
if (options.port) {
this.socketOptions = {
port: options.port,
hostname: options.hostname || 'localhost',
secure: options.secure,
};
} else this.socketOptions = defaultSocketOptions;
this.socketOptions = {
...defaultSocketOptions,
secure: options.secure ?? defaultSocketOptions.secure,
hostname: options.hostname ?? defaultSocketOptions.hostname,
port: options.port ?? defaultSocketOptions.port,
};
this.suppressConnectErrors =
options.suppressConnectErrors !== undefined