Skip to content

[Due for payment 2026-09-21] [Onyx] Investigate ConstraintError: Key already exists in the object store storage error #100047

Closed

Description

@fabioh8010

Parent issue: #87844

Coming from: #87844 (comment)

Sentry issue: https://expensify.sentry.io/issues/APP-E0

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. elirangoshen commented on Sep 2, 2026

    @elirangoshen
    Contributor

    Hi I investigated and its not an Onyx bug. It comes from Convert Experiences, the third-party A/B testing service we load on every web page:

    <!-- web/index.html:45 -->
    <script src="//cdn-4.convertexperiments.com/v1/js/10042537-100413459.js"></script>

    Their SDK keeps its own IndexedDB database (convert, stores config and signals) and inserts rows with add() instead of put():

    let t = await get({key:1, store:'config'});
    t ? await put({key:1, data})   // row there -> overwrite
      : await add({key:1, data});  // row missing -> insert

    add() fails if the key already exists; put() overwrites. Between the read and the write nothing reserves the key, so two runs at once (two tabs, or two calls in one tab) both take the add() branch, and the second one fails with ConstraintError: Key already exists in the object store. Nothing catches the rejection, so it reaches window.onunhandledrejection — our Sentry handler — and gets filed against our project.

    Why it is not Onyx:

    • Onyx's IndexedDB provider only uses put, delete, get, clear. There is no add() in onyx 3.0.101 or in idb-keyval.
    • Chromium prints "Key already exists in the object store." only for add(). Checked in a real browser: add() on an existing key gives that exact message, put() on the same key succeeds, and the error carries no stack — which matches the missing stacktrace and DOMException.code: 0 on the Sentry events.

    We already filter a sibling error from the same script. setupSentry.ts ignores Non-Error promise rejection captured with value: No data found for key, with a comment naming the Convert script.

    Proposed fix, same pattern as that one: add ConstraintError: Key already exists in the object store. to ignoreErrors in setupSentry.ts. thirdPartyErrorFilterIntegration cannot handle it, because the error has no stack frames to tag. Onyx never calls add(), so no real Onyx failure is hidden, and genuine storage errors still reach our logs.

    The add() → put() change itself sits in vendor code, so it needs a ticket to Convert. Tracking that separately.

  2. fabioh8010 commented on Sep 3, 2026

    @fabioh8010
    ContributorAuthor

    @mountiny looks like the same issue addressed in #99819, if you agree we can create a PR for this

  3. elirangoshen commented on Sep 7, 2026

    @elirangoshen
    Contributor

    Hi, I will be in vacation from tomorrow (08.09) until 15.09
    I will find someone from my team to continue to work on this issue while I'm away

  4. kacper-mikolajczak commented on Sep 8, 2026

    @kacper-mikolajczak
    Contributor

    Hi! I will fill in for @elirangoshen here. @mountiny I was told you are the one to reach out to for the PR review. Let me know what you think aobut the proposed solution. Thanks!

  5. mountiny commented on Sep 9, 2026

    @mountiny
    Contributor

    Answered on the pr

  6. melvin-bot commented on Sep 10, 2026

    @melvin-bot

    Triggered auto assignment to @AndrewGable, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  7. 3 remaining items

  8. mountiny commented on Sep 15, 2026

    @mountiny
    Contributor

    We can close this now

  9. abzokhattab commented on Sep 19, 2026

    @abzokhattab
    Contributor

    looks like payment was missing here,, can we please reopen @mountiny

    cc @mallenexpensify

  10. changed the title [-][Onyx] Investigate `ConstraintError: Key already exists in the object store` storage error[/-] [+][Due for payment 2026-09-21] [Onyx] Investigate `ConstraintError: Key already exists in the object store` storage error[/+] on Sep 21, 2026
  11. melvin-bot commented on Sep 21, 2026

    @melvin-bot

    Current assignee @mallenexpensify is eligible for the Awaiting Payment assigner, not assigning anyone new.

  12. melvin-bot commented on Sep 21, 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
  13. mallenexpensify commented on Sep 23, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @abzokhattab due $250 via NewDot

  14. quinthar commented on Sep 25, 2026

    @quinthar
    Contributor

    Approved $250 to @abzokhattab

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 productionDailyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions