Skip to content

PLAT-36990: recover never-bridged backfill messages and default empty sync params#283

Draft
Fizzadar wants to merge 2 commits into
mainfrom
nick/plat-36990-empty-sync-params
Draft

PLAT-36990: recover never-bridged backfill messages and default empty sync params#283
Fizzadar wants to merge 2 commits into
mainfrom
nick/plat-36990-empty-sync-params

Conversation

@Fizzadar

Copy link
Copy Markdown
Member

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 later ChatResync forward 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, so getSyncParams() returned an empty string for the Contact sync channel (database 2). Meta's server then failed every connect with Sync 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-unhandled LSHandleSyncFailure at 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

Fizzadar and others added 2 commits June 15, 2026 13:27
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant