Commit 321087d
authored
Fix join flow: skip stale groups in discovery + add sync fallback (#517)
* Skip self-created single-member groups in discoverNewConversations
When consumeInboxOnly() is used for the scanner flow, the pre-created
'New Convo' group exists in XMTP but may be cleaned up from the local DB.
discoverNewConversations() would then re-discover it and write it back
with isUnused: false, making it visible as 'New Convo' in the list.
Skip groups where we are the creator and the only member — these are
unused pre-created conversations that should not be re-introduced.
* Add discovery loop fallback for join flow
The XMTP conversation stream does not call sync_welcomes() at startup
(unlike StreamAllMessages), so it cannot discover groups the client is
added to after stream subscription. This causes the join flow to get
stuck at 'Verifying' indefinitely when the stream fails to deliver.
Add requestDiscovery() to SyncingManager that runs syncAllConversations
+ discoverNewConversations on demand. Thread it through InboxStateMachine
and InboxStateManager protocols.
In ConversationStateMachine.handleJoin, start a discovery loop alongside
the DB observation that periodically syncs welcomes with backoff
(3s, 6s, 12s, 15s cap). The DB observation fires as soon as the group
is written by discoverNewConversations. The loop is cancelled on success,
cancellation, or error.
* Remove accidentally committed .mote-preview.html
* Add .mote-preview.html to gitignore
* Remove investigation and plan docs
* Fix duplicate MessagingService creation in messagingServiceSync
messagingServiceSync could create duplicate services for the same
clientId when called concurrently. The nonisolated getAwakeService
check and the async registerExternalService had a race window where
two callers would both see nil and both create services.
Add getOrSetAwakeService to InboxLifecycleManager that atomically
checks the lock-based cache and stores the service if no entry exists.
If a duplicate is detected, the redundant service is stopped immediately.
* Revert "Fix duplicate MessagingService creation in messagingServiceSync"
This reverts commit 630481d.
* Stop orphaned duplicate services in registerExternalService
When messagingServiceSync is called concurrently for the same clientId,
duplicate MessagingService instances can be created before the first
one is registered. The second call to registerExternalService finds
the inbox already tracked and previously just silently returned,
leaving the duplicate's SyncingManager running orphaned streams.
Now stop the rejected service so its streams and auth flow are cleaned up.
* Address PR feedback: stop duplicate at call site, add deinit cleanup
Move duplicate service stop() from registerExternalService to the
caller in SessionManager. registerExternalService now returns Bool
indicating success — the caller stops the orphan if registration
was rejected. This avoids stopping a service that another caller
may already be using.
Also add discoveryTask?.cancel() to ConversationStateMachine deinit
for consistency with other task cleanup.1 parent 9a0de6e commit 321087d
12 files changed
Lines changed: 163 additions & 7 deletions
File tree
- ConvosCore
- Sources/ConvosCore
- Inboxes
- Mocks
- Sessions
- Syncing
- Tests/ConvosCoreTests
- qa/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
| |||
169 | 172 | | |
170 | 173 | | |
171 | 174 | | |
| 175 | + | |
172 | 176 | | |
173 | 177 | | |
174 | 178 | | |
| |||
668 | 672 | | |
669 | 673 | | |
670 | 674 | | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
671 | 696 | | |
672 | 697 | | |
673 | 698 | | |
674 | 699 | | |
675 | 700 | | |
676 | 701 | | |
| 702 | + | |
| 703 | + | |
677 | 704 | | |
678 | 705 | | |
679 | 706 | | |
| |||
691 | 718 | | |
692 | 719 | | |
693 | 720 | | |
| 721 | + | |
| 722 | + | |
694 | 723 | | |
695 | 724 | | |
696 | 725 | | |
| |||
699 | 728 | | |
700 | 729 | | |
701 | 730 | | |
| 731 | + | |
| 732 | + | |
702 | 733 | | |
703 | 734 | | |
704 | 735 | | |
| |||
757 | 788 | | |
758 | 789 | | |
759 | 790 | | |
| 791 | + | |
| 792 | + | |
760 | 793 | | |
761 | 794 | | |
762 | 795 | | |
| |||
863 | 896 | | |
864 | 897 | | |
865 | 898 | | |
| 899 | + | |
| 900 | + | |
866 | 901 | | |
867 | 902 | | |
868 | 903 | | |
| |||
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
352 | 353 | | |
353 | 354 | | |
354 | 355 | | |
355 | | - | |
| 356 | + | |
| 357 | + | |
356 | 358 | | |
357 | 359 | | |
358 | | - | |
| 360 | + | |
359 | 361 | | |
360 | 362 | | |
361 | 363 | | |
| |||
365 | 367 | | |
366 | 368 | | |
367 | 369 | | |
368 | | - | |
| 370 | + | |
369 | 371 | | |
370 | 372 | | |
371 | 373 | | |
372 | 374 | | |
373 | 375 | | |
| 376 | + | |
374 | 377 | | |
375 | 378 | | |
376 | 379 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
312 | 317 | | |
313 | 318 | | |
314 | 319 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
163 | 165 | | |
164 | 166 | | |
165 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
166 | 173 | | |
167 | 174 | | |
168 | 175 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| 103 | + | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
288 | 292 | | |
289 | 293 | | |
290 | 294 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
440 | 441 | | |
441 | 442 | | |
442 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
443 | 450 | | |
444 | 451 | | |
445 | 452 | | |
| |||
610 | 617 | | |
611 | 618 | | |
612 | 619 | | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
613 | 636 | | |
614 | 637 | | |
615 | 638 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
652 | | - | |
| 652 | + | |
| 653 | + | |
653 | 654 | | |
654 | 655 | | |
| 656 | + | |
655 | 657 | | |
656 | 658 | | |
657 | 659 | | |
| |||
0 commit comments