Commit 3cc5974
committed
fix(discord): add circuit breaker for WebSocket resume loop (#13180)
When the Discord WebSocket connection enters a stall loop (connects but
never receives HELLO), the existing zombie timeout handler would
disconnect and reconnect indefinitely. The library's reconnectAttempts
counter resets on every WebSocket open event, so the maxAttempts circuit
breaker is never reached.
This adds an application-level circuit breaker:
- Track consecutive stalls (WS opens but no HELLO within 30s)
- After 5 consecutive stalls, invalidate the session state (sessionId,
resumeGatewayUrl) and force a fresh IDENTIFY instead of resume
- Log stall count on each attempt for observability
- Reset counter on successful HELLO receipt
This breaks the infinite resume loop observed in production where 1400+
reconnect attempts occurred over 12+ hours with a stale session token.
Fixes: #131801 parent 4e9f933 commit 3cc5974
1 file changed
+49
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
634 | 634 | | |
635 | 635 | | |
636 | 636 | | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
637 | 640 | | |
| 641 | + | |
638 | 642 | | |
| 643 | + | |
639 | 644 | | |
640 | 645 | | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
641 | 655 | | |
642 | 656 | | |
643 | 657 | | |
| |||
646 | 660 | | |
647 | 661 | | |
648 | 662 | | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
656 | 698 | | |
657 | 699 | | |
658 | 700 | | |
| |||
0 commit comments