Commit c837786
authored
Properly close streams on exception (#167)
Why
===
We've had persistent timeout errors in AI-Infra, and I suspect that it's
related to not handling bumps in the connection correctly.
What changed
============
- WebSocket drops or send failures left _streams populated, so any
in-flight RPC hung until the session fully shut down. That meant clients
didn’t see an abort signal and could block indefinitely even though the
transport was already defunct.
- Added _abort_all_streams() in src/replit_river/session.py#L289 and
call it from both client_session.serve() and server_session.serve() on
ConnectionClosed, FailedSendingMessageException, or any other unexpected
exception (src/replit_river/client_session.py#L95,
src/replit_river/server_session.py#L82). This immediately closes every
active channel and clears _streams, ensuring callers are notified right
away when the socket dies so they can retry or surface an error.
Test plan
=========
CI/CD, ran against an internal branch with no issues 3x without flake.1 parent dcec28b commit c837786
2 files changed
+17
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
107 | 109 | | |
108 | 110 | | |
| 111 | + | |
| 112 | + | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
112 | 116 | | |
| 117 | + | |
113 | 118 | | |
114 | 119 | | |
115 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
289 | 300 | | |
290 | 301 | | |
291 | 302 | | |
| |||
310 | 321 | | |
311 | 322 | | |
312 | 323 | | |
313 | | - | |
314 | | - | |
315 | | - | |
| 324 | + | |
316 | 325 | | |
317 | 326 | | |
318 | 327 | | |
| |||
0 commit comments