-
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
[$250] Chat - Group is created with duplicate user when chat is started quickly on a slow network #49931
Comments
Triggered auto assignment to @RachCHopkins ( |
Please clarify the "actual result" |
Waiting on a response/clarification from QA team. |
team is still able to reproduce group.chat.mp4 |
Ok, to sum up, it can be reproduced and we don't know what/who the third user is. |
Job added to Upwork: https://www.upwork.com/jobs/~021843049310841478139 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat ( |
Edited by proposal-police: This proposal was edited at 2024-10-07T12:12:00Z. ProposalPlease re-state the problem that we are trying to solve in this issue.After sending the message, the chat turns into a group with duplicate users. It only corrects itself back to a single chat after switching to another chat and then returning to it What is the root cause of that problem?When App/src/libs/actions/QueuedOnyxUpdates.ts Lines 11 to 15 in 04214cd
We've had the logic to flush the queue after all requests are complete here App/src/libs/Network/SequentialQueue.ts Lines 172 to 174 in 04214cd
But in this case after App/src/libs/actions/OnyxUpdates.ts Lines 147 to 153 in 04214cd
After What changes do you think we should make in order to solve the problem?
App/src/libs/Network/SequentialQueue.ts Line 192 in 04214cd
What alternative solutions did you explore? (Optional) |
ProposalPlease re-state the problem that we are trying to solve in this issue.On slow networks, if we create a report and comment on it, a group with a duplicate chat is created. What is the root cause of that problem?For write requests, we do not write the response onyxData and the corresponding successData/failureData/finallyData to Onyx directly. Instead, we write them to queuedOnyxUpdates to prevent the replay effect. App/src/libs/actions/OnyxUpdates.ts Lines 30 to 32 in 78e484f
These updates are flushed only after all the PersistedRequests are cleared. App/src/libs/Network/SequentialQueue.ts Lines 173 to 175 in 78e484f
We remove a request from persistent requests only after the response is received and processed with all middlewares. App/src/libs/Network/SequentialQueue.ts Lines 90 to 99 in 78e484f
So, on slow networks, when we call OpenReport, its response and corresponding request’s successData, etc., are added to queuedOnyxUpdates. This cannot be flushed immediately because there was already an AddComment request added to the PersistedRequests. For some reason that needs to be fixed, the backend sends a previousUpdateID for AddComment that is larger than the previous lastUpdateID/lastClientUpdateID. This makes doesClientNeedToBeUpdated true.
As a result, the AddComment response is not processed directly with OnyxUpdates.apply. It sets this AddComment response to saveUpdateInformation, and the queue is paused. When the queue is paused, the updates waiting in queuedUpdates are not flushed, so OpenReport’s successData waits in the queuedUpdates, and the optimistic user detail is not removed, making the report appear like a group report. What changes do you think we should make in order to solve the problem?
DeferredOnyxUpdates.getMissingOnyxUpdatesQueryPromise()?.finally(finalizeUpdatesAndResumeQueue).then(() => QueuedOnyxUpdates.flushQueue()); What alternative solutions did you explore? (Optional) |
@parasharrajat, @RachCHopkins Whoops! This issue is 2 days overdue. Let's get this updated quick! |
@parasharrajat do you like any of the proposals here? |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
@RachCHopkins I won't be available from 16 Oct for a few days, please reassign. |
I can take over this issue as C+ |
@parasharrajat @RachCHopkins this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks! |
📣 @DylanDylann 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
Oops. I'm not sure if that matters 😬 |
@DylanDylann how do you feel about the proposals here? |
on my list today |
It will take me a bit of time to dive deep into this issue because this seems be complicated |
@c3024 Could you help to detail this point? |
Sure! fastNetworkDM.mp4
correctChain.mp4
There is a fix required on the backend for the first AddComment response after the OpenReport response. However, there is also a generic problem in the frontend codebase, as mentioned in the RCA and the second point of my suggested solution. The issue is that the last write response (in this case, AddComment, along with the updates waiting in queuedOnyxUpdates) which triggered the GetMissingOnyxMessages call, is not immediately written after the missing updates are fetched though the SequentialQueue is paused after fetching these missed updates. This happens because there is no code to flush the queuedUpdates unless another response is received from the backend, as outlined in the second point of my solution.
Feel free to ask if there is still something unclear. As you mentioned, this is a fairly complex issue, and I may have missed explaining some parts fully in an effort to keep the comments concise. |
@c3024 Thanks for a deep explanation |
@DylanDylann My solution here can fix both issues. @nkdengineer your updated solution is the same as mine. |
Why do you think it is expected? |
Hi @mkzie2, Thanks for your contribution, your solution and @nkdengineer's solution have the same idea. But the @nkdengineer proposed it first in #46393 (comment) |
I'm not sure about the logic of it, that's my guess. |
Thanks everyone for your inputs I agree with @c3024 about your RCA
🎀 👀 🎀 C+ reviewed |
Triggered auto assignment to @aldo-expensify, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
@c3024 Please give your concern if there is any problem. I really appreciate your investigation with details of RCA |
That is fine. It is necessary for PersistedRequests to be empty before flushing the queue. While I explained it in the next |
hmm, thanks @c3024 for that detailed explanation: #49931 (comment) I gave it a first read, I didn't understand 100% because I'm not very familiar with all that, but I think I understood that there is a backend bug related to the onyx updates ids being passed around. If this is true, I'd prefer to prioritize and fix that first, and then see again where we are at with this bug. I'll give it sometime later today to try to reproduce your detailed steps and see if I can understand/see the bug. |
@RachCHopkins, @aldo-expensify, @DylanDylann Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
I fail that day and then I forgot to come back. I'll try to take a better look at this asap |
not overdue, waiting for @aldo-expensify |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 9.0.41-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
The chat with the selected user should remain a 1-on-1 chat. The chat should not change into a group with duplicate users
Actual Result:
After sending the message, the chat turns into a group with duplicate users. It only corrects itself back to a single chat after switching to another chat and then returning to it
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
Bug6619285_1727614560806.1.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @DylanDylannThe text was updated successfully, but these errors were encountered: