Commit 92626fa
committed
fix(baileys): resolve incoming message events not working after reconnection
- Add cleanup logic in mount() to prevent memory leaks from multiple subscriptions
- Recreate messageSubject if it was completed during logout
- Remount messageProcessor in connectToWhatsapp() to ensure subscription is active after reconnection
This fixes the issue where incoming message events stop working after logout and reconnect, while outgoing message events continue to work normally.
The root cause was that onDestroy() calls complete() on the RxJS Subject, making it permanently closed. When reconnecting, the Subject would silently ignore all new messages.
The fix ensures that:
1. Old subscriptions are properly cleaned up before creating new ones
2. If the Subject is closed, a new one is created automatically
3. The messageProcessor is remounted on every connection to ensure active subscription1 parent 3454bec commit 92626fa
File tree
2 files changed
+21
-0
lines changed- src/api/integrations/channel/whatsapp
2 files changed
+21
-0
lines changedLines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
22 | 38 | | |
23 | 39 | | |
24 | 40 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
710 | 710 | | |
711 | 711 | | |
712 | 712 | | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
713 | 718 | | |
714 | 719 | | |
715 | 720 | | |
| |||
0 commit comments