Repository navigation
Commit c108489
fix(llminternal): guard RunLive errChan sends so abandoned producers exit on reconnect (#1167)
* fix(llminternal): guard RunLive errChan sends so abandoned producers exit on reconnect
RunLive's reader and sender goroutines did bare sends on the unbuffered,
per-attempt errChan. Once the consumer loop stops reading that channel --
after a resumable-error reconnect, a parent context cancellation, or any
other teardown -- cleanup() closes the connection, the producer's in-flight
call fails, and its send blocks forever, leaking one goroutine (plus its
captured connection state) per occurrence. Long-lived /run_live servers
accumulate these across sessions and reconnects.
Guard all three sends with the same select-on-connCtx idiom the function
already uses for eventsChan. cleanup() always cancels connCtx before the
next attempt (and before returning), so a guarded send is guaranteed to
unblock. connCtx, not ctx: ctx outlives reconnects and would not unblock
an abandoned producer.
The regression test fakes the Gemini Live wire protocol over a local
websocket server and fails deterministically on the unfixed code with
goroutines parked in 'chan send' at the bare-send sites.
Fixes #1152
* test(llminternal): cover the SendRealtime guard and stop the leak detector failing open
Addresses review feedback on the RunLive errChan leak fix.
runLiveStacks sized its buffer once at 1 MiB and never checked for
truncation. runtime.Stack truncates silently, so a dump larger than the
buffer would under-count parked goroutines and let a real leak pass --
the wrong failure direction for a leak detector. Grow until the whole
dump fits.
Add a case driving RealtimeInput across a connection loss. Reverting only
the SendRealtime guard left every existing case green, so that third
errChan send site was uncovered; nothing in the suite populated
LiveRequest.RealtimeInput. Each of the three guards is now caught
individually when reverted.
Rename "non-resumable error terminates" and record why it passes with or
without the guards: the sender exits through the existing connCtx.Done()
arm, so nothing is stranded. It pins terminal-path behaviour rather than
guarding the leak regression.
---------
Co-authored-by: westerberg <[email protected]>1 parent d1fd187 commit c108489
2 files changed
Lines changed: 409 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
373 | 376 | | |
374 | 377 | | |
375 | 378 | | |
| |||
386 | 389 | | |
387 | 390 | | |
388 | 391 | | |
389 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
390 | 396 | | |
391 | 397 | | |
392 | 398 | | |
| |||
427 | 433 | | |
428 | 434 | | |
429 | 435 | | |
430 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
431 | 440 | | |
432 | 441 | | |
433 | 442 | | |
| |||
436 | 445 | | |
437 | 446 | | |
438 | 447 | | |
439 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
440 | 452 | | |
441 | 453 | | |
442 | 454 | | |
| |||
0 commit comments