-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
fix: race condition when forwarding livechat by splitting subscription removal #33381
Conversation
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: a0b1672 The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #33381 +/- ##
===========================================
- Coverage 58.35% 58.35% -0.01%
===========================================
Files 2692 2692
Lines 65264 65265 +1
Branches 14729 14730 +1
===========================================
Hits 38084 38084
- Misses 24402 24403 +1
Partials 2778 2778
Flags with carried forward coverage won't be shown. Click here to find out more. |
/patch |
Pull request #33389 added to Project: "Patch 6.12.2" |
…ocket.Chat into feat/airgapped-restrictions * 'feat/airgapped-restrictions' of github.com:RocketChat/Rocket.Chat: (57 commits) fix: Async E2EE key exchange not working on develop (#33378) chore: Move Apps-Engine to monorepo (#32951) chore(Sidepanel): uses only local channels and discussions (#33387) chore: add gazzodown preview (#33279) fix: Avoid notifying `watch.settings` on uncaught errors (#33376) fix: race condition when forwarding livechat by splitting subscription removal (#33381) chore: Single Contact ID: improved typings and removed some duplicated code (#33324) ci: remove Jira-GitHub security integration (#33384) chore: add ui-composer to storybook (#33383) regression: `Sidepanel` sort requires refresh after room update (#33370) ci: use node20 for release action (#33343) Bump rocket.chat to 6.14.0-develop (#33366) chore: replace Meteor._localStorage -> Accounts.storageLocation (#33356) Release 6.13.0-rc.1 fix: Avoid destructuring `connectionData` when value is undefined (#33339) feat: Adds new admin feature preview setting management (#33212) regression: `Sidepanel` color highlight (#33342) chore: move common files to core-services (#33341) feat: Adds new admin feature preview setting management (#33212) chore: create network broker package (#33338) ...
As noted in CORE-696, when a livechat agent forwards a user to another department or agent, the user's chat can sometimes remain stuck in the sidebar of the old agent. Upon investigation, it was found that the old agent (the one forwarding the user) doesn't receive the expected socket event for the subscription deletion, which is crucial for clearing the user from their sidebar.
This issue was introduced in #32540 with the implementation of the
BaseRaw.findOneAndDelete
method, which is intended to remove a record from a collection and move it to the corresponding trash collection. However, due to the behavior of the RocketChat server's DB Watcher, between the deletion of the record and its insertion into the trash collection, the MongoDB change stream triggers a notification that initiates the DB Watcher flow. The DB Watcher then receives the subscription's trash ID and attempts to find it in the trash collection. At this point, however, the record hasn’t yet been inserted, resulting in a null response. Consequently, the notification of the subscription removal is lost, leaving the user's chat stuck in the old agent's sidebar.Proposed changes (including videos or screenshots)
This PR modifies the flow of the
findOneAndDelete
method to first insert the removed document into the trash collection before deleting it from the original collection. Additionally, a rollback condition has been implemented to revert the removal if the trash insertion fails.Further comments
Shoutout to @matheusbsilva137 and @sampaiodiego for their help in investigating and identifying the root cause of the problem. Your contributions were invaluable!