Skip to content

[Due for payment 2026-10-23] [$175] [Exploratory] Lost chat messages when login same account login on third device #100791

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.4.75-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #99774
Email or phone of affected tester (no customers): gocemate+buzz1993@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: windows 10/chrome
App Component: Chat Report View

Action Performed:

  1. Sign in on two devices to the same account and open the same chat on both
  2. Send some messages from both devices
  3. Login same account from third device

Expected Result:

Messages should not disappear from other devices

Actual Result:

Messages disappears from other devices

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

bandicam.2026-09-10.10-35-02-951.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7255503

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit

Activity

  1. applause-bot commented on Sep 10, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/48ba01e6e8b1c7d04c1fe1ff3a55883ee29825cd4274259c45d6cf8cc7645dee

  2. added
    Bug
    on Sep 24, 2026
  3. MelvinBot commented on Sep 24, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    A full ReconnectApp replaces the report-actions collections instead of merging into them, and it is triggered account-wide over Pusher — so a device that never signed in gets its stored chat messages wiped.

    The reconnectApp Pusher event is delivered on the per-account channel private-encrypted-user-accountID-<accountID> (src/libs/PusherUtils.ts:19-20, src/CONST/index.ts:2841), not a per-device one. Every signed-in device of the account receives it, regardless of which device caused it.

    The handler then chooses between an incremental and a full reconnect — and only anonymous users get the safe branch (src/libs/actions/User.ts:912-922):

    // Anonymous public-room sessions already have report actions from OpenReport. A full ReconnectApp
    // uses setCollection and clears them, which flashes the loading skeleton until GetNewerActions
    // refills. Pass lastUpdateID so reconnect stays incremental for anonymous users (#97847).
    if (isAnonymousUser()) {
        reconnectApp(lastUpdateIDAppliedToClient);
    } else {
        reconnectApp();
    }

    Calling reconnectApp() with no argument sets isFullReconnect = true (src/libs/actions/App.ts:496), and that response is applied unconditionally — the "this update is older than our state" guard is explicitly skipped for full reconnects (src/libs/actions/OnyxUpdates.ts:173-177). Anything the device held that is not in the payload is dropped.

    Signing in on a third device is what makes the server decide some device's updateIDFrom is unservable (the event fires "when we detect that the user passed updateID is not in the DB"). The resulting reconnectApp broadcast then hits all devices, so the two devices that were chatting happily lose messages they already had.

    The exact same mechanism already produced a shipped bug for anonymous users: [Due for payment 2026-09-25] Public room - Public room loads infinitely after dismissing AI modal. The fix there patched only the anonymous branch.

    Supporting evidence, what I verified vs. inferred, and a second (separate) bug found nearby

    Verified in App code at e029fad:

    • The Pusher channel is per-account, so reconnectApp reaches every device of the account.
    • Signed-in users unconditionally take the full-reconnect branch.
    • A full reconnect bypasses the staleness guard and always overwrites.
    • App applies whatever onyxMethod the server names, with no client-side guard — set/setcollection on reportActions_ is permitted by the type (src/types/onyx/Request.ts:18-32) and passed straight to Onyx.update. setcollection removes every collection member absent from the payload.

    Not verified (needs backend eyes): that the ReconnectApp response genuinely carries setcollection for reportActions_, and what makes the server emit reconnectApp when a third session is created. The comment quoted above asserts the first; I could not confirm it from this repo. That part is a backend/internal question.

    Also worth noting — how a partial loss becomes a large visual loss. Report-action continuity is tracked by the separate reportActionsPages_<reportID> key, and the rendered chain is hard-truncated at the newest page's last resolvable index (src/libs/PaginationUtils.ts:449-455). If the page row shrinks or splits, everything older stops rendering even though it is still in Onyx — the repo's own test asserts this (tests/unit/PaginationUtilsTest.ts:254-284). There is no proactive gap detection; the only automatic backfill requires the chain to yield zero visible actions (src/hooks/useBackfillWhenNoVisibleActions.ts:61-90). A partially truncated chat self-heals only when the user scrolls to the end.

    Alternative explanation I considered and set aside. Count in-flight Pusher applies as applied when detecting update gaps (merged 2026-09-09, the PR linked in the report) plus the warning in [Due for payment 2026-09-25] A single rejected Pusher apply poisons pusherEventsPromise, stopping all Pusher Onyx updates for the session describe a watermark-advances-past-a-failed-update data loss path. That was closed by the highestFailedUpdateID latch that shipped with the poisoned-promise fix, and it is regression-tested (tests/unit/OnyxUpdatesPusherChainFailureTest.ts:33-72). It also only explains new messages never arriving, not messages already on screen vanishing, so it does not fit this report.

    Separate latent bug found while auditing that path (not this issue — worth its own issue). The failure latch is only armed when the failed update's ID is still above the live watermark (src/libs/actions/OnyxUpdates.ts:249-268). The deferred-WRITE path detaches its advance from the returned promise (:277-287) with no ordering against other transports, so a higher-ID update can advance the watermark first and the later flush failure then silently fails to arm the latch. No test interposes a successful higher-ID update between a staged WRITE and its failed flush. I could not execute a reproducing Jest run in this environment, so treat this as read-only analysis.

    What changes do you think we should make in order to solve the problem?

    Make the signed-in branch incremental too, exactly as the anonymous branch already is — in src/libs/actions/User.ts:912-922, pass lastUpdateIDAppliedToClient to reconnectApp() for all users, and fall back to a full reconnect only when the client genuinely has no watermark. The server already returns a full payload when it cannot serve the requested range, so this keeps the recovery path intact while stopping a healthy device from discarding data it correctly holds.

    Two things a reviewer should decide alongside that:

    1. Should reconnectApp be a per-account broadcast at all? A stale updateIDFrom belongs to one device. Scoping the event to the affected device would remove the blast radius entirely. That is a backend change, so it needs an internal engineer.
    2. Confirm the setcollection-on-reportActions_ behaviour of ReconnectApp. If the response merges rather than replaces, the wipe has a different cause and this proposal needs revisiting.

    What alternative solutions did you explore? (Optional)

    • Guard setcollection on reportActions_ client-side. Rejected — it hides a server/client contract mismatch rather than fixing it, and would break legitimate full-refresh cases.
    • Make the chat view repair a truncated chain automatically by widening useBackfillWhenNoVisibleActions from "zero visible actions" to "any detected break". Worth doing as defence in depth, but it repairs the symptom after the data is already gone, so it is not the fix.

    Confidence: medium. The App-side mechanism is verified line by line and the symptom matches it precisely, including why it takes a third device. I have not confirmed it with a live repro or production logs, and one link in the chain (what the server sends and what triggers the broadcast) is backend.

    How to confirm in one run: reproduce with two devices chatting, open the JS console on one of them, then sign in on a third. The decisive marker is [App] isLoadingReportData set to true with command: 'ReconnectApp (full)' appearing on a device that did not sign in.

    I did not find an existing open issue covering this.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/100791) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  4. added
    External
    on Sep 24, 2026
  5. melvin-bot commented on Sep 24, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @nyomanjyotisa (External)

  6. melvin-bot commented on Sep 24, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. nyomanjyotisa commented on Sep 24, 2026

    @nyomanjyotisa
    Member

    @MelvinBot’s proposal looks good. Reproduced on staging and verified the fix locally, including recovery with an unavailable update ID.

    🎀 👀 🎀 C+ reviewed

  8. 24 remaining items

  9. added
    Weekly
    Daily
    Awaiting Payment
    and removed
    Daily
    Weekly
    on Oct 18, 2026
  10. melvin-bot commented on Oct 22, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  11. melvin-bot commented on Oct 22, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  12. mallenexpensify commented on Oct 26, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @nyomanjyotisa due $175 via NewDot
    Contributor+: @abzokhattab due $175 via NewDot

  13. trjExpensify commented on Nov 30, 2026

    @trjExpensify
    Contributor

    approved $175 for @nyomanjyotisa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternalNot a priority

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions