Commit 8b4eeea
Fix WebSocket connection accumulation across gateway restarts
Three listener leaks caused handlers to pile up on each in-process reload:
- notification.added_to_channel was registered in StreamChatClientRuntime.start()
but never removed; stop() now saves the reference and calls client.off() on it.
- ai_indicator.stop was registered in startAccount but handleAbort only removed
message.new; extracted to handleAiStop so it can be cleaned up properly.
- Added module-level activeGatewayCleanup registry: startAccount force-invokes
any stale cleanup for the same accountId before opening a new connection,
self-healing the case where the framework reloads without calling stop() first.
- handleAbort is now idempotent via a `stopped` boolean guard.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 794d8da commit 8b4eeea
3 files changed
Lines changed: 38 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
| |||
471 | 476 | | |
472 | 477 | | |
473 | 478 | | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
474 | 489 | | |
475 | 490 | | |
476 | 491 | | |
| |||
508 | 523 | | |
509 | 524 | | |
510 | 525 | | |
511 | | - | |
512 | | - | |
513 | 526 | | |
514 | | - | |
515 | | - | |
| 527 | + | |
516 | 528 | | |
517 | 529 | | |
518 | | - | |
519 | | - | |
520 | 530 | | |
521 | 531 | | |
522 | 532 | | |
| |||
525 | 535 | | |
526 | 536 | | |
527 | 537 | | |
528 | | - | |
| 538 | + | |
529 | 539 | | |
530 | | - | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
531 | 545 | | |
| 546 | + | |
| 547 | + | |
532 | 548 | | |
| 549 | + | |
| 550 | + | |
533 | 551 | | |
534 | 552 | | |
535 | 553 | | |
| |||
542 | 560 | | |
543 | 561 | | |
544 | 562 | | |
| 563 | + | |
| 564 | + | |
545 | 565 | | |
546 | 566 | | |
547 | 567 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | | - | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
69 | | - | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| |||
0 commit comments