Commit fa7963a
authored
fix(agent-proxy): survive a client that drops during agent-VM startup (#10880)
agent_ws accepts the client socket before booting the user's agent VM, and
_wait_for_vm_healthy polls for up to 120s — far past uvicorn's WebSocket
keepalive window. When the phone is dropped mid-wait ("sent 1011 keepalive
ping timeout"), the startup path's unguarded send_text/close raised
WebSocketDisconnect straight out of the handler: 24 "Exception in ASGI
application" tracebacks per day on prod agent-proxy, every one of them at the
"Agent VM is not responding" send.
The relay loop below already owned this condition (except Exception plus a
guarded final close); the startup path did not. Route every startup status,
error, and close through one client-liveness seam that treats peer-gone as the
terminal, expected end of the connection, so the handler still emits its
intended 4002/4003 close code and returns cleanly.
Verified: backend/tests/unit/test_agent_proxy_startup_client_gone.py drives the
real agent_ws against a socket that raises WebSocketDisconnect on every write —
both cases fail with the production exception on the parent commit and pass
here; the sibling agent-proxy suite stays green (8 passed).
Failure-Class: FC-peer-close-aborts-owed-write1 parent 3c9e830 commit fa7963a
2 files changed
Lines changed: 146 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
429 | 454 | | |
430 | 455 | | |
431 | 456 | | |
| |||
624 | 649 | | |
625 | 650 | | |
626 | 651 | | |
627 | | - | |
| 652 | + | |
628 | 653 | | |
629 | 654 | | |
630 | | - | |
631 | | - | |
| 655 | + | |
| 656 | + | |
632 | 657 | | |
633 | 658 | | |
634 | 659 | | |
635 | 660 | | |
636 | 661 | | |
637 | 662 | | |
638 | | - | |
639 | | - | |
| 663 | + | |
| 664 | + | |
640 | 665 | | |
641 | 666 | | |
642 | 667 | | |
643 | | - | |
| 668 | + | |
644 | 669 | | |
645 | 670 | | |
646 | | - | |
647 | | - | |
| 671 | + | |
| 672 | + | |
648 | 673 | | |
649 | 674 | | |
650 | 675 | | |
651 | 676 | | |
652 | 677 | | |
653 | | - | |
654 | | - | |
| 678 | + | |
| 679 | + | |
655 | 680 | | |
656 | 681 | | |
657 | 682 | | |
| |||
Lines changed: 111 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
0 commit comments