Skip to content

[Due for payment 2026-09-17] Make every lost receipt name the code path that killed it #100034

Closed

Description

@melvin-bot

Receipts captured while offline or on a weak connection wait in an upload queue until the network recovers. Onyx.clear() empties that queue, and eleven session-teardown paths call it. We already log a [Receipt] namespace covering capture, submit, enqueue, and drop-on-missing-file, plus a queue snapshot at sign-out and at backgrounding. Over five days in early August, 4–5 users per day signed out while receipts were still queued, and those receipts disappeared.

Problem

When a receipt is destroyed, we don't know the specific reason why. That makes the issue hard to track and hard to fix, and we have no accurate statistics on which path is the most harmful.

We do now show a modal warning users who manually sign out with receipts still queued, and the logs confirm it fires correctly. But it only covers the manual sign-out path. Other paths trigger the sign-out flow, and today we can't tell which one caused a loss.

Solution

Put enough detail on every loss to name its specific cause.

  • Give each of the eleven paths a value in a CONST.SIGN_OUT_REASON constant, and make it a required first argument of redirectToSignIn.
  • Widen the queue snapshot line. It already exists and already names the receipt, but it can't point to a specific path. Every pending receipt gains six fields: reason, snapshotID, pendingReceiptCount, msSinceEnqueued, isSourceInDurableFolder, platform.
  • Log the one loss that happens while the user is still signed in. When the queue abandons a receipt-bearing request after exhausting retries, emit a gaveUp event with the trace id. Cancelled and duplicate-record discards stay silent — the sign-out snapshot already covers the first, and nothing is lost in the second.
  • On the existing dropped line, carry the stat() error code so the reason a file went missing arrives already joined to the capture. Sentry gets the code but not the raw message, which contains the file path.

Outcome

In the best case we confirm sign-out is not the main cause of the remaining lost receipts. If it is, we'll know which path triggered it and have enough context to find the proper fix.

Scope

This does not stop receipts from being lost. Stopping the loss is a separate effort already in progress.

Draft PR: #99065

Reported in Slack.

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    ReviewingHas a PR in review
    and removed on Sep 2, 2026
  2. melvin-bot commented on Sep 15, 2026

    @melvin-bot
    Author

    @mountiny @rinej

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

  3. 5 remaining items

  4. melvin-bot commented on Sep 17, 2026

    @melvin-bot
    Author

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  5. Eskalifer1 commented on Sep 17, 2026

    @Eskalifer1
    Contributor

    Oh, totally missed that one!

  6. Eskalifer1 commented on Sep 17, 2026

    @Eskalifer1
    Contributor

    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: N/A - new feature

    • [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

    • [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.

      I don't think it's worth adding test here, since it's just logging. But if you have other opinion lmk!

  7. melvin-bot commented on Sep 17, 2026

    @melvin-bot
    Author

    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
  8. mallenexpensify commented on Sep 21, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @Eskalifer1 paid $250 via Upwork

    @Eskalifer1 can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022102185761303745707

  9. Eskalifer1 commented on Sep 22, 2026

    @Eskalifer1
    Contributor

    Hi @mallenexpensify, i have accepted, thank you!

  10. mallenexpensify commented on Sep 22, 2026

    @mallenexpensify
    Contributor

    @Eskalifer1 paid, summary updated above. Thx.

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionReviewingHas a PR in reviewTaskWeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions