xmtp / libxmtp

LibXMTP is a shared library encapsulating the core functionality of the XMTP messaging protocol, such as cryptography, networking, and language bindings.
MIT License
42 stars 18 forks source link

First Message Missed from stream after login #1106

Closed nplasterer closed 4 days ago

nplasterer commented 1 week ago

First Message Missed: There is a bug where the first message after local cache removal does not appear. I was able to replicate it https://xmtp-labs.slack.com/archives/C07JX15FG4F/p1727366626940349?thread_ts=1726867257.414269&cid=C07JX15FG4F

fabriguespe commented 4 days ago

Thanks @richardhuaaa for the explanation: After you redeploy, and initialize libxmtp, you're creating a new installation under the hood. When other users send messages to your bot, they only send to the list of installations for your bot that they know about. They will check for new installations if they haven't checked in the last 2s. So there's two gaps here where your new installation can miss messages:

richardhuaaa commented 4 days ago

For other's reference, fix is to keep the DB on bot redeploys, so that it is one continuous installation and no messages are lost. For non-bot use-cases, a new installation only gets messages going forward (up to 2s after the SDK is initialized). Historical messages can be retrieved via message backups, when we ship that