Repository navigation
Retry a 1:1 message's sync to our own swarm through the job queue - #2260
Merged
mpretty-cyro merged 4 commits intoNov 17, 2026
Merged
Conversation
A send job always marked its message as sending, so a job that only copies an already-delivered message to our own swarm would show it as unsent again. The job now carries whether it is such a sync, persisted with it so a resumed job keeps it; jobs persisted without it are ordinary sends.
After a 1:1 message reached its recipient, the copy to our own swarm was a one-shot coroutine. Any transient failure left the delivered message showing "Failed to sync" permanently: nothing retried it, and a restart couldn't either because there was no job to resume. A stored message's sync is now a send job with the same retry and backoff as any send, and is resumed after a restart. Messages with no stored record, such as call signalling, keep the best-effort sync.
A landed sync went through the same success handling as a first send, which started the message's timer again from the moment it landed. Now that a sync can land minutes later, on a retry or after a restart, a disappearing message stayed on the sending device for that much longer than on any other. A sync of an already-sent message now leaves the timer alone and shortens its own-swarm copy to expire at the sent time plus the timer, which is when linked devices expire it.
A send job whose message was deleted, or had expired, before it ran stopped without marking itself done, so its row stayed and was resumed at every launch only to stop again. The same happened when a send failed for a message deleted in the meantime. Each of these now finishes the job. Sync jobs made this far more common, since one is queued for every stored 1:1 message.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
After a 1:1 message reaches its recipient, a copy goes to your own swarm so your other devices get it. That copy was sent once from a coroutine. If the send failed, nothing retried it, and nothing could after a restart, because there was no job to resume. One transient network failure left a delivered message showing a red "Failed to sync" for good, and restarting the app didn't clear it. Reported in support ticket 28907.
Changes
MessageSender: a stored message's sync is now aMessageSendJobto our own swarm. It gets the same 10 attempts and backoff as any send, andJobQueue.resumePendingJobsresumes it after a restart, so no separate startup sweep is needed. A message with no stored record, such as call signalling, keeps the best-effort coroutine: it has no status to get stuck, and replaying call messages after a restart would be wrong.MessageSendJob: a job can be marked as a sync of a message that was already sent, and that marker is persisted with the job. Such a job marks the message SYNCING on each attempt rather than SENDING. The destination can't tell the two apart, because Note to Self also sends to our own swarm and does need SENDING. Jobs persisted before this change have no marker and stay ordinary sends.MessageSender/ExpiringMessageManager: a landed sync of an already-sent message no longer goes throughonMessageSent. That restarted the disappearing-message timer from the moment the sync landed, which now that a sync can land minutes later would keep the message on the sending device for that much longer than anywhere else.onMessageSyncedleaves the local timer alone and shortens the own-swarm copy to expire at its sent timestamp plus the timer, which is when linked devices expire it. Because the local timer is never restarted by a sync, a sync that runs at launch can't extend a message whose timer has already passed. Note to Self is still a first send and still starts its timer when it lands.MessageSendJob: a job whose message was deleted, or had expired, before it ran now finishes instead of stopping without marking itself done. Before, its row stayed and was resumed at every launch only to stop again. The same applies when a send fails for a message deleted in the meantime: the job is removed rather than left behind. This affected first sends too, but sync jobs, one per stored 1:1 message, made it far more common.Stored server hash. This doesn't change which hash is stored: a successful sync still replaces the recipient-swarm hash with the own-swarm one. What changes is when that happens. It can now be minutes later or after a restart, and far fewer messages are left with the recipient-swarm hash because their sync failed for good. See #2258.
In-flight sync vs UnsendRequest: won't be fixed in this client. It's low priority, and it is being tracked for Session 2.0 rather than this client. If a sync attempt is already in flight when the user deletes for everyone, the sync can land in our own swarm after the UnsendRequest, and a linked device may then show the message. Each attempt checks whether the message was deleted before it starts. That covers deletes during backoff and before a resumed job runs, so the remaining window is the flight time of the attempt that lands. That's normally one attempt, the same as before this change. The only addition is an attempt that stored the message but reported failure. This race exists on
devtoday, and the 1:1 delete marks the message deleted locally only after its own-swarm delete completes. A sync job can't close it alone: after landing it could remove its own copy, but a device that already fetched it would still show the message. A fix that doesn't depend on order belongs in the delete path or on the receiving side.Open questions, not changed here
isSyncMessage = trueand nosyncTarget. It re-sends to the recipient's swarm and marks the message sent. The label clears, but linked devices still don't get the message.Testing
SyncToSelfTest(10 tests). It drives the realMessageSender.scheduleSyncToSelf,JobQueueandMessageSendJob. The fake network sits atMessageSender.sendNonDurably, because encoding a message needs libsession's native library, which can't load in JVM tests. It covers:onMessageSynced, notonMessageSent, and a landed Note to Self send still callsonMessageSent;ExpiringMessageManagerSyncTest(3 tests), with a five-minute after-send timer and a sync that lands four minutes late: the local timer isn't restarted and the own-swarm copy is shortened to the sent time plus five minutes; the same message as a first send starts its timer when it lands; a message with no timer shortens nothing.onMessageSent, the job not passing the marker toMessageSender, the copy shortened from the landing time, a sync restarting the local timer, and each of the three deleted-message exits leaving the job in place.:app:testPlayDebugUnitTest --rerun-tasks: 435 tests, 0 failures.:app:assemblePlayDebugbuilds.