fix: messages not being sent, waiting forever for decryption to finish - WPB-17866 #3074
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.
This PR was automatically cherry-picked based on the following PR:
Original PR description:
Issue
Context: Messages are stuck forever in a sending state, no way to recover. Next messages can't be sent as well, stuck in same state.
We introduced in this PR a mechanism that waits for pending events to be decrypted before proceeding to message sending.
Specifically in
MessageSender
, we await forincrementalSyncObserver.waitUntilCanSendMessage()
and it only gets through when finishing decrypting the pending events and setting thedecryptionState
to done at theIncrementalSyncObserver
level.Causes: The decryption state might never gets updated to
.done
hence blocking the message sender to proceed the message which can lead to the bugs mentioned here and here.What happens after is that if we try to send a message again we'll be stuck in a loop in
try await messageDependencyResolver.waitForDependenciesToResolve(for: message)
where the dependencies never resolve specificallydependentObjectNeedingUpdateBeforeProcessing
(code doc below) will never be nil, probably because the initial message was never really processed and it blocks the next messages./// Other entities which has to complete an update before this entity can be processed, i.e. another message /// needs to be sent first because it was scheduled for sending before this message.
Solution: Update the sync state whenever the sync is suspended or when an error occurs while pulling (and decrypting) pending events so we ensure the decryption state is changed to done so the
MessageSender
method is "unlocked" and the messages are sent or at least attempted to be sent.Testing
Tested internally
Checklist
[WPB-XXX]
.UI accessibility checklist
If your PR includes UI changes, please utilize this checklist: