Skip to content
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

[HOLD for payment 2023-08-21] [$1000] Offline - Can't leave public room after send message #23572

Closed
1 of 6 tasks
kavimuru opened this issue Jul 25, 2023 · 30 comments
Closed
1 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented Jul 25, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Login 2 account on 2 browsers
  2. A create a public room and copy share url
  3. B open room url
  4. B force offline
  5. B send message in a room
    6, B click header => leave room
  6. B toggle offline => Online, Observed that the public room reappeared in LHN

Expected Result:

public room does not reappear in LHN does not reappear after leaving the room

Actual Result:

public room reappeared in LHN does not reappear after leaving the room

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.45-3
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

Screen.Recording.2023-07-25.at.12.25.08.mov
Recording.1337.mp4

Expensify/Expensify Issue URL:
Issue reported by: @namhihi237
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690263033683239

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01c85f976eb6d66e14
  • Upwork Job ID: 1684936418739585024
  • Last Price Increase: 2023-07-28
  • Automatic offers:
    • mollfpr | Reviewer | 25899685
    • tienifr | Contributor | 25899689
    • namhihi237 | Reporter | 25899696
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 25, 2023

Triggered auto assignment to @laurenreidexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Jul 25, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@kavimuru kavimuru changed the title Offline - Can't leave publich room after send message Offline - Can't leave public room after send message Jul 25, 2023
@samh-nl
Copy link
Contributor

samh-nl commented Jul 25, 2023

When going online again, OpenReport is called followed by LeaveRoom.
Apparently the OpenReport data is still used, even through it should've be overwritten.
Looks like a race condition in Onyx when combining merge and set, same cause as another issue (#22064).

@tienifr
Copy link
Contributor

tienifr commented Jul 25, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Although the public room was left in offline mode, it appears again on LHN after switching to online.

What is the root cause of that problem?

When we leave the room in offline mode, the room's report data was optimistically all cleared including its named and only left with statusNum and stateNum.

When we switched to online, AddComment was called first, an Onyx.merge is returned to update the new message. Immediately after that, LeaveRoom returns an Onyx.set to clear the report. These two operations happen nearly at the same time. Here, race condition occurs. The set is supposed to clear all data of the report but gets overwritten by the merge (though the set should fire after the merge). This is a known issue in Onyx where Onyx.set is called after Onyx.merge but eventually the merge overwrites the older value made by the set: #5930.

Since the merge did not return the report name, the room's report name is undefined. That triggers the ReconnectToReport call and eventually re-joins the room:

// A report can be missing a name if a comment is received via pusher event and the report does not yet exist in Onyx (eg. a new DM created with the logged in person)
// In this case, we call reconnect so that we can fetch the report data without marking it as read
if (report.reportID && report.reportName === undefined) {
reconnect(report.reportID);
}

What changes do you think we should make in order to solve the problem?

This is a known and tricky issue in Onyx and as concluded in the attached thread, there's not so much we can do to completely fix the root cause in Onyx. The key point is we should not use set after merge. I suggest an alternative way to clear the room's report using merge.

Inside leaveRoom here, we extract all the keys from the report, "nullify" all of them, then use the "nullified" report as the successData:

successData: [
    {
        onyxMethod: Onyx.METHOD.MERGE,
        key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
        value: _.object(reportKeys, Array(reportKeys.length).fill(null)),
    },
],

@tienifr
Copy link
Contributor

tienifr commented Jul 26, 2023

@samh-nl You should not post your proposal in this way. You have previously posted a comment yesterday but that was not a proposal. If you have a new proposal, please post it in a new and separate comment. Btw, your proposal looks somewhat similar to mine so be clear about that.

@samh-nl
Copy link
Contributor

samh-nl commented Jul 26, 2023

@tienifr I'd have no problem with posting it in a new comment and reverting my previous post for clarity.

@samh-nl
Copy link
Contributor

samh-nl commented Jul 26, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Can't leave public room after send message while offline.

What is the root cause of that problem?

The cause is that when the user becomes online, OpenReport is called in the BE followed by LeaveRoom.

OpenReport returns the report using an Onyx merge, while LeaveRoom clears the report to null using Onyx set.

This leads to incorrect behavior, where the set is ignored in favor of the merge (reported before #22064 and #5930). Therefore leaving the room intact.

What changes do you think we should make in order to solve the problem?

Option 1. Onyx must correctly process merge and set, where set should take precedence if it's called later.
Option 2. We can change the set into a merge statement: add [reportId]: null to clear the record, this should preferentially be done in the BE to replace the current response, but could also be passed as successData in Report.leaveRoom.

What alternative solutions did you explore? (Optional)

N/A

@melvin-bot melvin-bot bot added the Overdue label Jul 27, 2023
@laurenreidexpensify laurenreidexpensify added the External Added to denote the issue can be worked on by a contributor label Jul 28, 2023
@melvin-bot melvin-bot bot changed the title Offline - Can't leave public room after send message [$1000] Offline - Can't leave public room after send message Jul 28, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 28, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01c85f976eb6d66e14

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 28, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 28, 2023

Current assignee @laurenreidexpensify is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Jul 28, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @mollfpr (External)

@laurenreidexpensify
Copy link
Contributor

Not overdue

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jul 28, 2023
@laurenreidexpensify
Copy link
Contributor

@mollfpr bump for review on these proposals thanks

@melvin-bot melvin-bot bot removed the Overdue label Jul 31, 2023
@mollfpr
Copy link
Contributor

mollfpr commented Jul 31, 2023

Reviewing

@laurenreidexpensify
Copy link
Contributor

@mollfpr can you confirm if either of the solutions are 👍

@mollfpr
Copy link
Contributor

mollfpr commented Aug 1, 2023

Sorry for the delay, the BE changes will take longer to fix, and it's clearly set null to the report; we can do it in the E/App instead.

The proposal from @tienifr looks good to me 👍

🎀 👀 🎀 C+ reviewed!

@melvin-bot
Copy link

melvin-bot bot commented Aug 1, 2023

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

@MariaHCD
Copy link
Contributor

MariaHCD commented Aug 2, 2023

@tienifr's proposal looks good to me too.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 2, 2023

📣 @mollfpr 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot
Copy link

melvin-bot bot commented Aug 2, 2023

📣 @tienifr 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot
Copy link

melvin-bot bot commented Aug 2, 2023

📣 @namhihi237 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Aug 2, 2023
@tienifr
Copy link
Contributor

tienifr commented Aug 2, 2023

PR ready for review #24039

@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2023

Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:

  • when @tienifr got assigned: 2023-08-02 09:26:09 Z
  • when the PR got merged: 2023-08-10 07:13:26 UTC
  • days elapsed: 5

On to the next one 🚀

@MariaHCD
Copy link
Contributor

@laurenreidexpensify, the PR was merged late because I missed assigning another engineer here before I went OOO on Aug 3rd.

@tienifr should still be eligible for the bonus since the PR was ready for review and approved by @mollfpr within 3 working days.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Aug 14, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Offline - Can't leave public room after send message [HOLD for payment 2023-08-21] [$1000] Offline - Can't leave public room after send message Aug 14, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 14, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot
Copy link

melvin-bot bot commented Aug 14, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.53-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-08-21. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Aug 14, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@mollfpr] The PR that introduced the bug has been identified. Link to the PR:
  • [@mollfpr] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@mollfpr] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@mollfpr] Determine if we should create a regression test for this bug.
  • [@mollfpr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@laurenreidexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@laurenreidexpensify
Copy link
Contributor

laurenreidexpensify commented Aug 18, 2023

Payment Summary:

  • External issue reporter - @namhihi237 $250, offer accepted in Upwork
  • Contributor that fixed the issue - @tienifr, $1000 + $500 bonus, offer accepted in Upwork
  • Contributor+ that helped on the issue and/or PR - @mollfpr, $1000 + $500 bonus, offer accepted in Upwork

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 Daily KSv2 labels Aug 21, 2023
@laurenreidexpensify
Copy link
Contributor

all payments have been issued in Upwork

@mollfpr can you please confirm checklist steps above thanks

@mollfpr
Copy link
Contributor

mollfpr commented Aug 22, 2023

Thanks, @laurenreidexpensify I'll complete the checklist ASAP.

@mollfpr
Copy link
Contributor

mollfpr commented Aug 23, 2023

[@mollfpr] The PR that introduced the bug has been identified. Link to the PR:
[@mollfpr] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:

No offending PR.

[@mollfpr] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:

This is a one-time bug, so a regression test should be enough.

[@mollfpr] Determine if we should create a regression test for this bug.
[@mollfpr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

  1. Login with any account
  2. Go to a room
  3. Go to Settings >> Preferences >> Force offline
  4. Send a message to the room
  5. Press room header >> Leave room
  6. Verify that the public room disappears from LHN
  7. Turn off Force offline
  8. Verify that the public room won't appear again in LHN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

6 participants