-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defer local updates if there are missing updates and only call GetMissingOnyxMessages
once
#38997
Defer local updates if there are missing updates and only call GetMissingOnyxMessages
once
#38997
Conversation
…tMissingOnyxMessages
…tMissingOnyxMessages
@danieldoglas could you take a look at the current implementation and just check, if this is at least somehow what you expected? just checking before i spend too much time on the actual implementation. I expect this PR to be done tomorrow if the current approach is feasible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few comments, but I think we're missing a few things:
- We should only apply the deferred updates if the current applied update is smaller than their lastUpdateID. Another way to see this is that we should only apply them if they are > the tha lastUpdateID in the
deferredUpdateBeforeReconnect
- By applying the item above, we need to confirm that the updates that were received are also linked correctly to the
deferredUpdateBeforeReconnect
- I'm not sure if there are gains in persisting the deferredUpdates or not. I think maybe not?
I updated the code so that we check for "old" deferred updates, that have already been applied through
Are case (1) and (2) expected to happen subsequently? As in my other comment, i might not fully understand case (1).
I don't think we need to persist the deferred values, since on a reload/restart we're fetching everything again anyway, right? Updated the code and tested it thoroughly. I'm manually skipping some updates locally to simulate XHR requests not reaching the client. The missing updates are received from @danieldoglas let me know what you think and maybe you can test this on your machine as well, so we're safe here... |
GetMissingOnyxMessages
GetMissingOnyxMessages
once
Not sure if we need a C+ on this one? @danieldoglas |
…tMissingOnyxMessages
I don't think we need a C+ on this one! Removing @getusha |
@danieldoglas just triggered another review request. Could you give this a look, so we can maybe merge this today? I'll try to be available in the evening, in case there are any issues. |
Confirmed it's also happening on Staging |
Yes, you can use it. But the goal of this test branch is to just receive some messages in any report (that were sent from another device+account) and then in the DevTools you will see a bunch of logs, that show, that the logic is working |
// In order for the deferred updates to be applied correctly in order, | ||
// we need to check if there are any gaps between deferred updates. | ||
type DetectGapAndSplitResult = {applicableUpdates: DeferredUpdatesDictionary; updatesAfterGaps: DeferredUpdatesDictionary; latestMissingUpdateID: number | undefined}; | ||
function detectGapsAndSplit(updates: DeferredUpdatesDictionary): DetectGapAndSplitResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a few examples or test cases here will be very helpful to understand the code.
Ok, I can confirm the logic worked on test branch Screen.Recording.2024-04-02.at.22.29.40.mov |
@hungvu193 @eh2077 please also confirm through the network tab that we're not executing several GetMissingOnyxUpdates at the same time while you're testing this |
Yep. I can confirm it as well. GetmissingOnyx.mov |
Co-authored-by: Eric Han <[email protected]>
…tMissingOnyxMessages
@eh2077 , anything else you've noted on this PR that we might need to change? |
@danieldoglas Sorry for the delay. I'm on it and let me look into the code and do some more tests. Will update in an hour. |
@chrispader I tested the case described in primary GH #38748. I found that sometimes GetMissingOnyxMessages was called two times. 0-API-call-2-times.mp4And the console log FYI |
@eh2077 I'm not sure about your case exactly, but this is intentional. When we find a gap in the deferred updates, We will trigger a second call to This is a recursive call in https://github.com/margelo/expensify-app-fork/blob/cd48514a02629f49f39d769425e6b866a8d9a4b6/src/libs/actions/OnyxUpdateManager.ts#L150 |
@chrispader I see. So, multiple API calls are expected as long as there's no overlapping of the updateID ranges of them, right? |
yes, basically. It might potentially be the case though, that the |
Reviewer Checklist
Screenshots/VideosAndroid: NativeN/AAndroid: mWeb ChromeN/AiOS: NativeN/AiOS: mWeb SafariN/AMacOS: Chrome / Safari0-API-call-2-times.mp4MacOS: DesktopN/A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and tested well.
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
@danieldoglas @hungvu193 Could you explain the step 3 in |
This seems to have cause this deploy blocker #39650 and this crash https://expensify.slack.com/archives/C049HHMV9SM/p1712264151436019 |
🚀 Deployed to production by https://github.com/Julesssss in version: 1.4.60-13 🚀
|
@danieldoglas
Details
Fixed Issues
$ #38748
PROPOSAL:
Tests
Test 1
I created a testing branch that prevents some updates from being applied (therefore
GetMissingOnyxUpdates
will be triggered) and has some useful logs.Either test in this branch or on your own. In
OnyxUpdateManager
do the following:applyDeferredUpdates
with asetTimeout
GetMissingOnyxUpdates
is triggereddeferredUpdates
objectGetMissingOnyxUpdates
are performedTest 2
App/src/libs/actions/Report.ts
Lines 769 to 789 in a4d01a8
Offline tests
Not needed.
QA Steps
Only Test 2 from "Tests"
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop
Tested deferring logic on web, iOS and Android. mWeb behavior is the same as in web...