Reapply "Remove macro/micro tasks during subscriber update"#760
Reapply "Remove macro/micro tasks during subscriber update"#760VickyStash wants to merge 3 commits intoExpensify:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1638ea180
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
lib/OnyxUtils.ts
Outdated
| if (lastConnectionCallbackData.has(mapping.subscriptionID) && shallowEqual(lastValue, value)) { | ||
| return; |
There was a problem hiding this comment.
Deduplicate connect hydration callbacks by key
sendDataToConnection() now suppresses callbacks using shallowEqual(lastValue, value) without considering matchedKey. For collection subscriptions that do not use waitForCollectionCallback, this can drop legitimate callbacks for different collection members when their payloads are shallow-equal (for example during connect() hydration racing with an immediate set(), where lastConnectionCallbackData is already populated). In that case some keys are never delivered to the subscriber, leaving the caller with an incomplete collection view.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@VickyStash did you take a look at this comment?
There was a problem hiding this comment.
I'll take a closer look in a bit!
… of collection member callbacks
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a19cc41cd0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
|
|
||
| return scheduleSubscriberUpdate(key, value, (subscriber) => hasChanged || subscriber?.initWithStoredValues === false).then(() => undefined); | ||
| keyChanged(key, value, (subscriber) => hasChanged || subscriber?.initWithStoredValues === false); |
There was a problem hiding this comment.
Prevent subscriber exceptions from aborting persistence
broadcastUpdate() now calls keyChanged() synchronously, and keyChanged() executes user-provided connect callbacks without a guard. If any subscriber callback throws, that exception bubbles out immediately and short-circuits callers like setWithRetry()/applyMerge() before Storage.setItem()/mergeItem() run, leaving cache updates visible but not persisted to storage. This regression is introduced by removing the deferred update path, so callback failures should be isolated (e.g., deferred or wrapped) to avoid data loss on write operations.
Useful? React with 👍 / 👎.
… subscriber errors from blocking storage updates
|
I didn't get tagged by melv on this PR. Will complete the review and testing today. |
Details
Second try for this PR #724
It was reverted here: #758
Check the issue description for details.
App PR: Expensify/App#85919
Related Issues
$ Expensify/App#82871
Automated Tests
Should be covered by existing tests + new
tests/unit/collectionHydrationTest.tsManual Tests
The E/App should work the same way as before. Let's verify basic test steps:
Author Checklist
### Related Issuessection aboveTestssectiontoggleReportand notonIconClick)myBool && <MyComponent />.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)Avataris modified, I verified thatAvataris working as expected in all cases)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.mp4
Android: mWeb Chrome
android_web.mp4
iOS: Native
ios.mov
iOS: mWeb Safari
ios_web.mov
MacOS: Chrome / Safari
web.mp4