fix: Livechat conversation not closing due to cross-tab interference#35168
Merged
kodiakhq[bot] merged 5 commits intodevelopfrom Feb 17, 2025
Merged
fix: Livechat conversation not closing due to cross-tab interference#35168kodiakhq[bot] merged 5 commits intodevelopfrom
kodiakhq[bot] merged 5 commits intodevelopfrom
Conversation
Contributor
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: 7d45a97 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #35168 +/- ##
========================================
Coverage 59.44% 59.44%
========================================
Files 2827 2827
Lines 68162 68162
Branches 15123 15123
========================================
Hits 40516 40516
Misses 24990 24990
Partials 2656 2656
Flags with carried forward coverage won't be shown. Click here to find out more. |
MartinSchoeler
approved these changes
Feb 13, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes (including videos or screenshots)
This PR mitigates a race condition happening on livechat and being reported intermittently on FLAKY-652.
The problem occurs when there's more than one tab running Livechat instance. When
Livechat.closeChatis called, all tabs receive the system messagelivechat-closeand initiate thecloseChat()procedure. After the first tab finished, all other tabs are blocked due to the room being already closed. This sometimes blocks the tab where the close chat request was originated, which is not the desired behavior.This PR mitigates this problem by:
closeChat()only when the system message is received.This prevents the routine from being called twice. It unifies the logic, close chat requests initiated by either agent or visitor will follow the same routine. Finally, chat transcript request params are received via system message, the previous behavior could end up not displaying the transcript modal.
closeChat()Initially the check was added was to prevent
closeChatfrom being called twice (onFinishedChatand system message), change1.takes care of this aspect. Since the function only executes client side mutations, it executing more than once in the same instance is problematic, but by different instances is acceptable.This is a palliative solution, since at this moment no form of mutex seems to allow for the cross-tab communication needed. This behavior will be revisited in the future for a more robust solution.
Issue(s)
Steps to test or reproduce
To reliably reproduce this issue it is necessary to have more than one tab running livechat (in sync) and intentionally delay the call to
processMessage(room.js) in one of the instances.This issue can also happen during normal use, but very sporadically.
Further comments
No new tests were added since our current tests already cover this specific scenario.