Skip to content

fix: Restart i/o when there are new transports in a sync message#7753

Merged
iequidoo merged 2 commits intomainfrom
iequidoo/start-io-for-synced-transport
Jan 29, 2026
Merged

fix: Restart i/o when there are new transports in a sync message#7753
iequidoo merged 2 commits intomainfrom
iequidoo/start-io-for-synced-transport

Conversation

@iequidoo
Copy link
Collaborator

@iequidoo iequidoo commented Jan 20, 2026

This currently fails because we don't start I/O for new transports synced from another device.

@iequidoo iequidoo added the bug Something is not working label Jan 20, 2026
@Hocuri
Copy link
Collaborator

Hocuri commented Jan 22, 2026

We could restart i/o immediately when receiving a new transport in a sync message, see the commit I just pushed. The future needs boxing and a + Send constraint for it to compile, because this is a recursive call.

Not sure that is the correct thing to do, however; we're in the middle of receiving messages, this is not a good time to cancel and restart i/o. OTOH, changing transports is rare, so, maybe it's fine. A somewhat more "correct" solution would be to somehow put a transports_changed flag on Context, and restart i/o when going IDLE.

cc @link2xt

@iequidoo
Copy link
Collaborator Author

Thanks for fixing! But i think it should be fix:, not feat:.

Not sure that is the correct thing to do, however; we're in the middle of receiving messages, this is not a good time to cancel and restart i/o. OTOH, changing transports is rare, so, maybe it's fine.

I think it's good enough, changing transports is rare indeed, also duplicate sync messages arriving from different transports shouldn't lead to restarting I/O multiple times because modified should be true only once. If it's not the case, that should be fixed as well, though it's minor. I was thinking about adding a one-second sleep, though usually i don't like such solutions.

But note that i really caught this bug when switching to chatmail, so it's not smth that cannot happen to users.

@iequidoo iequidoo requested a review from link2xt January 23, 2026 03:50
@Hocuri Hocuri force-pushed the iequidoo/start-io-for-synced-transport branch from c2dad53 to 78b8eac Compare January 24, 2026 11:14
@iequidoo iequidoo changed the title test: 2nd device receives message via new primary transport fix: Restart i/o when there are new transports in a sync message Jan 28, 2026
Copy link
Collaborator

@Hocuri Hocuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@link2xt told me that he's fine with this change

iequidoo and others added 2 commits January 28, 2026 21:41
This currently fails because we don't start I/O for new transports synced from another device.
@iequidoo iequidoo force-pushed the iequidoo/start-io-for-synced-transport branch from b2b5c4d to 7d6f8b7 Compare January 29, 2026 00:43
@iequidoo iequidoo merged commit 955f799 into main Jan 29, 2026
30 checks passed
@iequidoo iequidoo deleted the iequidoo/start-io-for-synced-transport branch January 29, 2026 01:00
@iequidoo
Copy link
Collaborator Author

iequidoo commented Feb 8, 2026

The fix here isn't enough however because we don't fetch exisitng messages from the new synced transport, see select_with_uidvalidity() (but it's a known thing). When the second device comes online, there are already messages from our contacts sent only to our new transport (NB: for outgoing messages it's not the case). To fix this properly the first device should probably send uid_next in the Transports sync message so that other devices fetch the same set of messages from a new or readded transport. Not sure it's fine to fetch all messages even if it's a chatmail transport which probably doesn't have infinite number of messages.

If we can't fix this quickly, maybe we need to tell users that they should make sure that their other devices successfully added the new transport, before making it primary.

@Hocuri
Copy link
Collaborator

Hocuri commented Feb 8, 2026

I created an issue for it: #7843

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is not working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants