PLAT-36990: recover never-bridged backfill messages and default empty sync params#283
Draft
Fizzadar wants to merge 2 commits into
Draft
PLAT-36990: recover never-bridged backfill messages and default empty sync params#283Fizzadar wants to merge 2 commits into
Fizzadar wants to merge 2 commits into
Conversation
Forward backfill pruned the fetched batch purely by timestamp, dropping every message older than the portal's latest bridged message on the assumption it was already bridged. Meta can skip threads in a reconnect snapshot while advancing the sync cursor past their messages, so a later ChatResync forward backfill fetches those missed messages and then discards them here, leaving permanent mid-timeline gaps (PLAT-36990). Before dropping a pre-anchor message, check whether it actually exists in the bridge database and recover it if it does not. The lookup only runs for the pre-anchor slice of a forward backfill batch and fails closed (drops as before) on DB errors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
messenger-lite sessions don't include LSPlatformMessengerSyncParams, so
getSyncParams returned an empty string for the Contact sync channel
(database 2). Meta's server then failed every connect with "Invalid
argument supplied for foreach()", the database never obtained a cursor,
and contact sync was permanently broken (PLAT-36990).
Fall back to {"locale":"en_US"} when the config value is empty, and
surface the previously-unhandled LSHandleSyncFailure at error level with
the database ID so this class of failure is visible.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Two independent fixes for a local Facebook (messenger-lite) bridge where Messenger messages that arrived while the bridge was offline were permanently lost, and contact sync was perpetually broken.
Fix 1 — recover never-bridged messages in forward backfill (
pkg/connector/backfill.go)wrapBackfillEvents()pruned the fetched forward-backfill batch purely by timestamp, dropping every message older than the portal's latest bridged message on the assumption it was already bridged. But Meta can answer a reconnect with a truncate+snapshot that skips some threads while advancing the sync cursor past their messages. A laterChatResyncforward backfill then fetches those missed messages and discards them here, leaving a permanent mid-timeline gap.Now, before dropping a pre-anchor message, we check whether it actually exists in the bridge database (
GetFirstPartByID) and recover it if it does not. The lookup only runs for the pre-anchor slice of a forward-backfill batch and fails closed (drops as before) on DB errors. The backward path is untouched.Fix 2 — default sync params when the page config omits them (
pkg/messagix/syncManager.go)messenger-lite sessions don't include
LSPlatformMessengerSyncParams, sogetSyncParams()returned an empty string for the Contact sync channel (database 2). Meta's server then failed every connect withSync failed with exception: Invalid argument supplied for foreach(), database 2 never obtained a cursor, and contact sync was permanently broken.We now fall back to
{"locale":"en_US"}when the config value is empty, and surface the previously-unhandledLSHandleSyncFailureat error level with the database ID so this class of failure is visible.Linear
PLAT-36990 — rainai2k26: Local Facebook receives Meta sync failures while affected Messenger chats remain stale
🤖 Generated with Claude Code