You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2024-07-10] Buildup of unused Pusher subscriptions #43089
Opening a workspace chat via the header in an IOU report doesn't unsubscribe from the IOU report's channel. These subscriptions then build up over time, so you can end up with a ton of AuthenticatePusher calls!
Actions taken
After opening 4 different reports, open an IOU report
Tap on the workspace name in the header
Expected result
you should see a log line that says the IOU report's pusher channel has been unsubscribed
Actual result
No such log line. The pusher channel subscription is maintained unnecessarily.
Please re-state the problem that we are trying to solve in this issue.
When tapping on the workspace name in the header. No such log line. The pusher channel subscription is maintained unnecessarily.
What is the root cause of that problem?
When we tap on the workspace name in the header, we can see the [Pusher] Unbinding event with eventName of client-userIsLeavingRoom. That means the isLeavingRoom event is cleaned up properly here.
However, the client-userIsTyping event is not cleaned up well, so the channel subscription remains.
The implementation to unsubscribe from client-userIsTyping is in
We can see that it only unsubscribe if the screen becomes unfocused. We're not unsubscribing when the screen unmounts, like we did with the client-userIsLeavingRoom in there.
So in case the screen unmounted completely, the client-userIsTyping is not unsubscribed.
What changes do you think we should make in order to solve the problem?
Unsubscribe the client-userIsTyping when the screen is unmounted.
We have the unsubscription logic here, we can put it in the clean up function of an useEffect
, unsubscribe both events, or unsubscribe the entire channel by calling unsubscribe with empty event name.
Also to note, we're subscribing and unsubscribing the userIsTyping and userIsLeaving in 2 different places, it's possible that we can combine them in 1 place, either the place of userIsTyping now or of the userIsTyping.
Activity
melvin-bot commentedon Jun 5, 2024
Current assignee @jjcoffee is eligible for the External assigner, not assigning anyone new.
melvin-bot commentedon Jun 5, 2024
Triggered auto assignment to @muttmuure (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.dominictb commentedon Jun 5, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
When tapping on the workspace name in the header. No such log line. The pusher channel subscription is maintained unnecessarily.
What is the root cause of that problem?
When we tap on the workspace name in the header, we can see the
[Pusher] Unbinding eventwitheventNameofclient-userIsLeavingRoom. That means theisLeavingRoomevent is cleaned up properly here.However, the
client-userIsTypingevent is not cleaned up well, so the channel subscription remains.The implementation to unsubscribe from
client-userIsTypingis inApp/src/pages/home/report/UserTypingEventListener.tsx
Line 52 in 432c2e7
We can see that it only unsubscribe if the screen becomes
unfocused. We're not unsubscribing when the screen unmounts, like we did with theclient-userIsLeavingRoomin there.So in case the screen unmounted completely, the
client-userIsTypingis not unsubscribed.What changes do you think we should make in order to solve the problem?
Unsubscribe the
client-userIsTypingwhen the screen is unmounted.We have the unsubscription logic here, we can put it in the clean up function of an
useEffectIn here we don't need to check for
topmostReportIdbecause in case of unmounting, of course the current report will no longer be shown to the user.Just to note this is the same pattern we used for unsubscribing from the userIsLeaving event
App/src/pages/home/ReportScreen.tsx
Lines 460 to 465 in 432c2e7
So after both events are unsubscribed correctly, the channel itself will be unsubscribed.
The logic to unsubscribe
userIsTypingis both used for unfocused and unmounted case, so it can be put in a method for DRY.What alternative solutions did you explore? (Optional)
In
App/src/pages/home/ReportScreen.tsx
Line 465 in 432c2e7
unsubscribewith empty event name.Also to note, we're subscribing and unsubscribing the
userIsTypinganduserIsLeavingin 2 different places, it's possible that we can combine them in 1 place, either the place ofuserIsTypingnow or of theuserIsTyping.jjcoffee commentedon Jun 5, 2024
@dominictb's proposal LGTM! I like the idea of having both events unsubscribe in the same
useEffect.🎀👀🎀 C+ reviewed
melvin-bot commentedon Jun 5, 2024
Current assignee @roryabraham is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.
25 remaining items
melvin-bot commentedon Jul 10, 2024
Payment Summary
Upwork Job
BugZero Checklist (@muttmuure)
roryabraham commentedon Jul 12, 2024
Thanks @jjcoffee. @muttmuure this is done - all that's left is to add the regression tests and pay this out
melvin-bot commentedon Jul 15, 2024
@jjcoffee, @muttmuure, @roryabraham, @dominictb Eep! 4 days overdue now. Issues have feelings too...
mallenexpensify commentedon Jul 16, 2024
@dominictb @jjcoffee , can you please accept the job and reply here once you have?
https://www.upwork.com/jobs/~01f0dc2c395e40f075
Thanks for the Regression Test steps @jjcoffee
dominictb commentedon Jul 16, 2024
@mallenexpensify Done, thanks 🙏
jjcoffee commentedon Jul 17, 2024
@mallenexpensify Accepted, thanks!
melvin-bot commentedon Jul 17, 2024
@jjcoffee, @muttmuure, @roryabraham, @dominictb 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
mallenexpensify commentedon Jul 19, 2024
Contributor: @dominictb paid $250 via Upwork
Contributor+: @jjcoffee paid $250 via Upwork