Commit 31a55b9
authored
Refactor ReconnectingWebSocket with state machine and fix config change reconnection (#744)
Introduce a formal state machine pattern for WebSocket connection management:
- Add ConnectionState enum (IDLE, CONNECTING, CONNECTED, AWAITING_RETRY,
DISCONNECTED, DISPOSED) to explicitly model the connection lifecycle
- Implement pure reducer function (reduceState) with action-based transitions
- Replace ad-hoc boolean flags (#isDisconnected, #isDisposed, #isConnecting,
#pendingReconnect) with single #state property
Fix excessive reconnection on configuration changes:
- Previously, config changes triggered reconnect() on all active sockets
- Now only sockets in DISCONNECTED state are reconnected, since connected
sockets will pick up settings naturally on their next reconnection cycle
- Prevents unnecessary connection churn when users modify settings
Closes #7541 parent b52e7a4 commit 31a55b9
File tree
7 files changed
+329
-102
lines changed- src
- api
- websocket
- workspace
- test/unit
- api
- websocket
7 files changed
+329
-102
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
5 | 10 | | |
6 | 11 | | |
7 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
167 | | - | |
| 168 | + | |
| 169 | + | |
168 | 170 | | |
169 | 171 | | |
170 | 172 | | |
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
175 | | - | |
176 | | - | |
177 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
178 | 183 | | |
179 | | - | |
| 184 | + | |
| 185 | + | |
180 | 186 | | |
181 | 187 | | |
182 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 53 | | |
59 | 54 | | |
60 | 55 | | |
| |||
0 commit comments