Repository navigation
Commit c4497e9
authored
fix(ui-web): refuse a held rpc call whose socket already closed (#1348)
## Summary
`whenOpen` is where a call waits while the socket is still connecting:
it attaches an `open` and a `close` listener and settles on whichever
fires. A socket that is already closing or closed when those listeners
go on never fires either event for that call, so the call stays pending
for the life of the page.
- Read the socket's state after both listeners are registered and reject
with the same `not connected` an absent socket answers. A socket still
connecting, or already open, stays with the listeners.
This check cannot fire on the browser path today: `send` only enters
`whenOpen` while `readyState` is `CONNECTING`, the registrations and the
state read run without an intervening task, and a native socket changes
`readyState` only between tasks. It is kept as a guard for the
`WebSocketLike` contract: an implementation that settles synchronously,
or a future `await` between the check and the registrations, can hand
over a closed socket whose close event has already gone out. The
comments say that rather than claiming a browser race.
Found while investigating #1347. The desk Tasks tab staying blank after
a reconnect is #1347's subject; this change hardens the held-call path
and does not claim to fix that symptom.
## Verification
- `node node_modules/vitest/vitest.mjs run src/rpc/wsTransport.test.ts`:
28 tests passed, 0 failed.
- The new case fails without the fix: the same call stays `pending`
after its socket closes as the listeners attach.
- `npm run type-check`: passed.
- `npm run lint`: 0 errors, 4 warnings, the same pre-existing ones in
`SubagentsPage`, `ConnectionsPage` and `CronPage`.
- The comment revision is comment-only (plus the case title): 28 tests
still pass, type-check and lint unchanged.
- `scripts/check_commit_messages.py origin/main..HEAD`: exit 0.
- `scripts/check_source_language.py origin/main..HEAD`: exit 0.
- `git diff --check origin/main...HEAD`: exit 0.
- The run read the tree under test: `tsc --listFiles` resolves that
tree's own `src`.1 parent c249c03 commit c4497e9
2 files changed
Lines changed: 45 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
253 | 281 | | |
254 | 282 | | |
255 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
36 | 37 | | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
293 | 295 | | |
294 | 296 | | |
295 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
296 | 311 | | |
297 | 312 | | |
298 | 313 | | |
| |||
0 commit comments