Repository navigation
Description
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:
App/src/libs/actions/OnyxUpdates.ts
Lines 105 to 117 in 4dbbd13
| 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
GetMissingOnyxMessagespath. - Deferred
PUSHER-type updates replayed byOnyxUpdateManager(utils/applyUpdates.ts:7→OnyxUpdates.apply) can never succeed either, because they go through the same poisoned chain. applyOnyxUpdatesReliablyis called without a.catchatsrc/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
- Add an explicit guard so a successful apply cannot advance
lastUpdateIDAppliedToClientpast an update whose apply failed, instead of relying on rejection propagation. - Reset
pusherEventsPromise(andairshipEventsPromise) toPromise.resolve()in a.catchso one failure does not kill the chain for the session. - 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.
- 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.
Activity
[-]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[/+]melvin-bot commentedon Sep 18, 2026
@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]
nyomanjyotisa commentedon Sep 21, 2026
Contributor+ Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: fix: ensure pusher events are processed in the same order they were received #31144 (comment)
Link to the comment on the Issue: [HOLD for payment 2023-11-29] [$1000] Removed reactions on offline mode re appear on the receiver account and there is no way to remove them #23679 (comment)
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A — assessed as non-critical.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
No additional manual regression test recommended: reproducing this failure requires injecting an apply rejection. Automated tests in #100594 cover Pusher/Airship recovery, failure propagation, ordering, and watermark continuity.
Do we agree 👍 or 👎
melvin-bot commentedon Sep 24, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Sep 24, 2026
Payment Summary
Resolving PRs:
Recover the Pusher apply chain after a rejection, behind a watermark continuity guard #100594
Contributor: @adhorodyski does not require payment (Contractor)
Reviewer: @nyomanjyotisa owed $175 via NewDot
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Sep 26, 2026
Payment Summary
Contributor+: @nyomanjyotisa due $250 via NewDot
trjExpensify commentedon Sep 28, 2026
approved $250 for @nyomanjyotisa