Commit eaa4123
fix: bias mini_agent serve() select toward shutdown over task exits
When shutdown_tx fires, each transport accept loop sees shutdown_rx,
drains its joinset, and returns Ok(()). Both the accept loop's
JoinHandle and the supervisor's shutdown_rx.changed() then become ready
in the same poll cycle. Without biased, the unbiased select! in serve()
would pick a *Died arm at random, return Err(...), and abort everything
without firing flusher_shutdown_tx — so the stats flusher's shutdown
branch never ran and no final stats POST happened. This made
test_mini_agent_*_with_real_flushers intermittently time out at 60s
waiting for /api/v0.2/stats; CI run 25562651282 captured the smoking
gun "Event::PipeDied: Ok(Ok(()))".
biased; with shutdown_rx.changed() listed first guarantees Event::Shutdown
wins whenever the shutdown signal is observable, so the supervisor always
takes the graceful-flush path even if the accept loops happen to resolve
first. Production main.rs never sends on shutdown_tx, so this is purely
a test-only path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 978e314 commit eaa4123
1 file changed
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
298 | 303 | | |
| 304 | + | |
| 305 | + | |
299 | 306 | | |
300 | 307 | | |
301 | 308 | | |
302 | 309 | | |
303 | 310 | | |
304 | | - | |
305 | 311 | | |
306 | 312 | | |
307 | 313 | | |
| |||
322 | 328 | | |
323 | 329 | | |
324 | 330 | | |
| 331 | + | |
325 | 332 | | |
| 333 | + | |
| 334 | + | |
326 | 335 | | |
327 | 336 | | |
328 | 337 | | |
329 | 338 | | |
330 | | - | |
331 | 339 | | |
332 | 340 | | |
333 | 341 | | |
| |||
0 commit comments