Skip to content

[Due for payment 2026-09-25] A single rejected Pusher apply poisons pusherEventsPromise, stopping all Pusher Onyx updates for the session #100174

Closed

Description

@MelvinBot

Problem

pusherEventsPromise in src/libs/actions/OnyxUpdates.ts:51 is a module-scoped promise that serializes Pusher applies. It is only ever reassigned from itself, and no link in the chain has a rejection handler:

function applyPusherOnyxUpdates<TKey extends OnyxKey>(updates: Array<OnyxUpdateEvent<TKey>>, lastUpdateID: number) {
pusherEventsPromise = pusherEventsPromise.then(() => {
Log.info('[OnyxUpdateManager] Applying pusher update', false, {lastUpdateID});
});
pusherEventsPromise = updates
.reduce((promise, update) => promise.then(() => PusherUtils.triggerMultiEventHandler(update.eventType, update.data)), pusherEventsPromise)
.then(() => {
Log.info('[OnyxUpdateManager] Done applying Pusher update', false, {lastUpdateID});
});
return pusherEventsPromise;
}

Every .then() there is onFulfilled-only. So when one Pusher apply rejects — for example a rejected Onyx.update inside the onyxApiUpdate handler at src/libs/actions/User.ts:941 — the promise stays rejected for the rest of the session. Every later Pusher update chains onto it, rejects immediately, and its handler never runs.

Verified empirically: hold a Pusher apply for update 20, reject it, then send update 30. Update 30's triggerMultiEventHandler is never called.

Consequences:

  • All Pusher-delivered Onyx updates stop applying for the rest of the session. The client can only recover through the HTTPS GetMissingOnyxMessages path.
  • Deferred PUSHER-type updates replayed by OnyxUpdateManager (utils/applyUpdates.ts:7 → OnyxUpdates.apply) can never succeed either, because they go through the same poisoned chain.
  • applyOnyxUpdatesReliably is called without a .catch at src/libs/actions/User.ts:913, so each of these surfaces as an unhandled promise rejection.

applyAirshipOnyxUpdates has the identical shape on airshipEventsPromise (lines 119-131) and should be fixed in the same change.

Rare — [OnyxUpdateManagerError] runs at roughly one per ten-minute band fleet-wide — but total for the affected client when it happens.

Why this needs its own issue

This is pre-existing on main and not introduced by #99774. It is filed separately because that PR's correctness currently depends on this bug.

#99774 adds a lastUpdateIDPendingApply marker so a Pusher update that is still applying counts as applied during gap detection. That lets a chained follow-up update through the gap check while the earlier apply is still in flight. Nothing in advanceLastUpdateIDAfterApply checks ID continuity — line 208 only checks monotonicity — so the only thing stopping the follow-up from advancing the watermark past a failed earlier update is that the poisoned chain makes it reject too.

Fixing this in isolation would silently turn #99774 into data loss: update A (10→20) fails, the chain resets, update B (20→30) succeeds, the watermark advances to 30, and updates 11–20 are gone with nothing left to trigger recovery.

So the fix here must land together with, or after, an explicit continuity guard in advanceLastUpdateIDAfterApply — not before.

Proposed approach

  1. Add an explicit guard so a successful apply cannot advance lastUpdateIDAppliedToClient past an update whose apply failed, instead of relying on rejection propagation.
  2. Reset pusherEventsPromise (and airshipEventsPromise) to Promise.resolve() in a .catch so one failure does not kill the chain for the session.
  3. Make the failure path explicitly trigger recovery (pause the queue and fetch the missing range) rather than leaving it to the next incidental gap check.
  4. Add a regression test that a Pusher update applies normally after an earlier one rejected.

Context

Found while reviewing #99774. The PR author flagged it in the PR description under "Known issue found while writing this, not fixed here". The test for the failure case in that PR works around it by using jest.resetModules() to load its own copy of the module.

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    Reviewing
    on Sep 3, 2026
  2. added
    Weekly
    and removed
    Daily
    on Sep 3, 2026
  3. added
    Daily
    and removed
    Reviewing
    Weekly
    on Sep 18, 2026
  4. changed the title [-]A single rejected Pusher apply poisons pusherEventsPromise, stopping all Pusher Onyx updates for the session[/-] [+][Due for payment 2026-09-25] A single rejected Pusher apply poisons pusherEventsPromise, stopping all Pusher Onyx updates for the session[/+] on Sep 18, 2026
  5. melvin-bot commented on Sep 18, 2026

    @melvin-bot

    @nyomanjyotisa

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.89-0 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-09-25. 🎊

    The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]

  6. nyomanjyotisa commented on Sep 21, 2026

    @nyomanjyotisa
    Member

    Contributor+ Checklist:

  7. added
    Weekly
    Daily
    Awaiting Payment
    and removed
    Daily
    Weekly
    on Sep 21, 2026
  8. melvin-bot commented on Sep 24, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  9. melvin-bot commented on Sep 24, 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
  10. mallenexpensify commented on Sep 26, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @nyomanjyotisa due $250 via NewDot

  11. trjExpensify commented on Sep 28, 2026

    @trjExpensify
    Contributor

    approved $250 for @nyomanjyotisa

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

Metadata

Metadata

Labels

Awaiting PaymentDailyTask

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions