fix: silent message loss after notification#7502
Conversation
…on tap 1. decryptMessages Promise.all killed entire db.write batch when any single message threw during decryption. Switched to Promise.allSettled so one bad message can't abort all writes (affects E2E rooms). 2. loadMissedMessages recursive pagination was fire-and-forget (no await), so page 2+ silently failed. Added await so all pages are sequenced and rejections propagate visibly. 3. updateMessages and loadThreadMessages mutated the original update array's message objects with , corrupting tmid on references captured by msgsToCreate/msgsToUpdate closures. Removed the mutation — it was useless for the DB write and harmful to the input data. closes issue with messages arriving as push notifications not appearing in chat view (non-E2E: fire-and-forget pagination; E2E: batch abort).
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…/RocketChat/Rocket.Chat.ReactNative into fix/message-loss-on-notification
|
Android Build Available Rocket.Chat 4.75.0.109385 Internal App Sharing: https://play.google.com/apps/test/RQQ8k09hlnQ/ahAO29uNRNWx81qznK7IQARwslK17U6fsL-PD6kSceJzNjpoYMfoneII8Zlp8OQ6Oy_khOEAZCYFqUvnqXA8prpWL_ |
|
iOS Build Available Rocket.Chat 4.75.0.109386 |
Proposed changes
Fixes three bugs that cause messages to arrive as push notifications but silently fail to appear in the chat view.
1.
Encryption.decryptMessages—Promise.allkills entiredb.writebatch (E2E rooms)Promise.allcauses the entiredb.write()callback to reject when any single message decryption throws.Promise.allSettledprevents one bad message from aborting the entire batch.2.
loadMissedMessages— fire-and-forget recursive paginationThe recursive call to load the next page was not awaited. If page 2+ fails (network timeout, server error), all subsequent messages are silently lost. Adding
awaitensures pages sequence correctly.3.
updateMessages/loadThreadMessages—delete threadMessage.tmidcorrupts inputThe mutation runs before the
msgsToCreate/msgsToUpdateclosures execute duringdb.batch(), corrupting the originalupdatearray and thread-message update closures.How to test or reproduce
Types of changes
Checklist