-
Notifications
You must be signed in to change notification settings - Fork 3k
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 2024-05-22] [$250] [Bug] ActiveClientManager doesn't track the currently active tab well and needs improved #40044
Comments
Job added to Upwork: https://www.upwork.com/jobs/~012e35885da3cd69cf |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Santhosh-Sellavel ( |
Triggered auto assignment to @isabelastisser ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.I believe Bug 1 is not an issue, since the client becomes the lead once the user activates the tab. two-tabs.mp4Bug 2 If active tab is closed, there are no active tabs What is the root cause of that problem?Bug 2. Indeed, when the second tab is closing, we still preserve its The root cause is that the following tab is not receiving updates on active clients. It still handles the list of active clients, which is not the least created one. What changes do you think we should make in order to solve the problem?I propose to add
In this case, any of the remaining app tabs will become a leader. And, as a bonus, the What alternative solutions did you explore? (Optional) |
ProposalPlease re-state the problem that we are trying to solve in this issueActiveClientManager does not track the current active tab correctly, especially when the active tab is closed. What is the root cause of that problem?Bug 1This can be viewed as a bug, or a desired outcome based on what is needed. If we want the currently active tab to be the client leader - then it works as expected The currently activated tab by the user, takes in the role of the "Active client". This means that when a user:
This means that we only have one client leader since it's activated when a user opens/reloads the tab. This happens because the const init: Init = () => {
activeClients = activeClients.filter((id) => id !== clientID);
activeClients.push(clientID);
ActiveClients.setActiveClients(activeClients).then(resolveSavedSelfPromise);
}; Bug 2When a tab is closed, the clientID is not released from the list of active clients. This causes the other tabs remain in an inactive state. What changes do you think we should make in order to solve the problem?Bug 1If we consider this a bug, then we can make the following changes. let isInitialized = false;
const init: Init = () => {
if( isInitialized ) return;
activeClients = activeClients.filter((id) => id !== clientID);
activeClients.push(clientID);
ActiveClients.setActiveClients(activeClients).then(resolveSavedSelfPromise);
isInitialized = true;
}; This results in the newly created/reloaded tab taking over as the active client as the The advantage of this is that the client leader does not keep changing as the user changes tabs, and only when a new tab is created/or an existing one is reloaded. Bug 2When a tab is closed, or the browser window is closed, we can detect this using the window.addEventListener("beforeunload", () => {
activeClients = activeClients.filter((id) => id !== clientID);
ActiveClients.setActiveClients(activeClients);
}) This will notify other tabs of the release of the currently active tab. What alternative solutions did you explore? (Optional)N/A |
📣 @gitaumoses4! 📣
|
Contributor details |
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
ProposalPlease re-state the problem that we are trying to solve in this issue.ActiveClientManager changes the leader tab whenever focus changes + client ID is not deleted from active clients on tab close and reload. What is the root cause of that problem?Bug 1:
Line 181 in 260a7de
This leads to init() being called in Lines 117 to 123 in 260a7de
Hence, whenever we switch to any tab, init method is called again and the focused tab becomes the leader. So, when only tab A is open, it is the leader as expected. Now, tab B is opened, then it becomes the leader as expected. Bug 2: The list of active clients does not update when a tab is closed. This means the list even contains clientIDs which are no longer active, hence the leader does not change if the leader tab is closed. What changes do you think we should make in order to solve the problem?Fix for bug 1:
We can remove this call:
And this method also:
Fix for bug 2: Add a handle tab close method:
Add an event listener for beforeunload:
This works with both tab close and page refresh (tested). Although, note that you need to click atleast once somewhere on the page before refreshing, otherwise |
@Santhosh-Sellavel Will you be able to look at these proposals today? |
Taking over as C+ |
@tgolen Are you sure that both tabs become the leader? As far as I can see, only the active tab (Tab A) is becoming the leader. |
I am not 100% sure about that, no. It sounds like most of the proposals here are able to disprove that theory. It was just what I was able to observe, which isn't actually what was happening. |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
@tgolen, do I need to assign a contributor to this issue since it's external, or are you going to work on this one? |
@isabelastisser @tgolen My proposal is available for review: #40044 (comment) |
@tgolen, @isabelastisser Whoops! This issue is 2 days overdue. Let's get this updated quick! |
@allroundexperts, please complete the checklist below. Thanks! 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:
|
PR hasn't been merged yet @isabelastisser |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
I just saw that there's a fixed PR for this, but I came here to say that my client was stuck and showing a lot of |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.73-7 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 2024-05-22. 🎊 For reference, here are some details about the assignees on this issue:
|
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:
|
This wasn't really a regression. It was more just a flaw with the original feature. I don't think this needs the checklist filled out or any regression tests created. |
Sounds good. Thanks @tgolen! I will process the payments on May 22. |
Payment Summary
BugZero Checklist (@isabelastisser)
|
@Skakruk, can you please share your Upwork profile? |
@isabelastisser here is my profile https://www.upwork.com/freelancers/~013b95670960c26f03 |
Thank you! all set. |
@isabelastisser I get paid through ND. Can you please update the summary? Thanks! |
Payment Summary Contributor: @Skakruk paid $250 via Upwork |
$250 approved for @allroundexperts |
Problem
The purpose of
ActiveClientManager
is to ensure that when there are multiple tabs open, only one tab handles write requests. There are a few bugs with this.In order to test this, I used the following diff and then ran
ActiveClientManager.isClientTheLeader()
from the command line.Bug 1: Multiple tabs becoming active
isClientTheLeader() === true
isClientTheLeader() === true
Expected result:
isClientTheLeader() === false
because TabB took over as the new leaderActual result:
isClientTheLeader() === true
and both tabs think they are the leaderBug 2: If active tab is closed, there are no active tabs
Note
I was unable to reproduce this because of Bug1. However, once Bug1 is fixed, I think this bug would happen.
Expected result:
Tab B takes over and becomes the new active client
Actual result:
Tab B remains as an inactive client
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @isabelastisserThe text was updated successfully, but these errors were encountered: