Repository navigation
[NoQA] Add failing tests documenting sequential queue persistence bugs - #83195
Conversation
This test verifies that API.write() resolves its promise immediately, without waiting for Onyx persistence to complete, highlighting a known issue with the persistence guarantee.
Tests document three additional bugs in the sequential queue persistence pipeline (parent issue Expensify#80759): - Issue 3c: processNextRequest() updates in-memory queue but never persists the change to disk, causing in-memory/disk divergence - Issue 4: rapid concurrent saves can lose requests when Onyx.set() calls resolve out of order (connect callback blindly overwrites in-memory state) - Issue 5: conflict resolvers read stale in-memory queue due to Issue 4, making deduplication decisions based on incomplete data All tests assert the current buggy behavior and include comments indicating which assertions to flip when the bugs are fixed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Resolving CI flagged issues now. |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. |
|
@bernhardoj Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d42d57515
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
🚀 Deployed to staging by https://github.com/mjasikowski in version: 9.3.27-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.27-8 🚀
|
@mjasikowski @OlimpiaZurek @TMisiukiewicz
Explanation of Change
This PR adds unit tests (that should fail when reversed without fixing their root causes) that document known bugs in the sequential queue's persistence pipeline, as described in issue #80759. No production code is changed — the tests are purely diagnostic and serve as a regression baseline for future fixes.
The tests cover five distinct bugs:
Issue 2 (
APITest.ts):API.write()resolves its returned promise immediately viaPromise.resolve(), with no connection to theOnyx.set()call insidePersistedRequests.save(). Callers thatawaitthe result ofAPI.write()have no guarantee that the request has been persisted to disk.Issue 3a (
PersistedRequests.ts):processNextRequest()moves the first queued request toongoingRequestin memory, but only persists it toPERSISTED_ONGOING_REQUESTSwhenpersistWhenOngoingistrue. No production code ever sets this flag, so all in-flight requests are unprotected against app crashes.Issue 3c (
PersistedRequests.ts):processNextRequest()updates the in-memory queue viapersistedRequests.slice(1)but never writes the updated array back toONYXKEYS.PERSISTED_REQUESTS. From the momentprocessNextRequest()is called untilendRequestAndRemoveFromQueue()completes, in-memory and disk state diverge.Issue 4 (
PersistedRequests.ts):save()performs a read-modify-write on the in-memory array and firesOnyx.set()without awaiting. Theconnectcallback blindly overwrites in-memory state with whatever disk returns. When two rapid saves resolve out of order, the stale write wins and the newer request is permanently lost.Issue 5 (
APITest.ts): Conflict resolvers inSequentialQueue.push()andAPI.prepareRequest()callPersistedRequests.getAll(), which reads in-memory state. Because Issue 4 can leave the in-memory queue stale, conflict resolvers make deduplication decisions based on an incomplete view of the queue.Each test asserts the current buggy behavior and includes inline comments marking exactly which assertions to invert once the corresponding bug is fixed.
Fixed Issues
$ #80759
PROPOSAL:
Tests
Offline tests
N/A
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari