From d2e5969e3e186ffb7d346bd0bba9bb2ae2d78197 Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Fri, 7 Apr 2023 06:54:38 +0000 Subject: [PATCH] [FIX] mail: indeterministic guest tour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes the `19916` issue on the `test_mail_channel_public_page_as_guest` test. The messaging service subscribes to bus notifications before it is fully initialized. This test is composed of two tours. In the first one, the guest joins the channel and receives the "guest has joined the channel" message. Then, the second tour starts and the local storage is cleared. Since the local storage has been cleared, the guest receives this message again, potentially before messaging has been initialized which leads to a `channel_pin` rpc. This RPC fails with `SessionExpired` error and the tour is stuck and eventually, fails. closes odoo/odoo#118000 Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/core/messaging_service.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/core/messaging_service.js b/addons/mail/static/src/core/messaging_service.js index 0c871bdd5a6..89fc0e97974 100644 --- a/addons/mail/static/src/core/messaging_service.js +++ b/addons/mail/static/src/core/messaging_service.js @@ -730,10 +730,12 @@ export const messagingService = { } const messaging = new Messaging(env, services); messaging.initialize(); - services.bus_service.addEventListener("notification", (notifEvent) => { - messaging.handleNotification(notifEvent.detail); + messaging.isReady.then(() => { + services.bus_service.addEventListener("notification", (notifEvent) => { + messaging.handleNotification(notifEvent.detail); + }); + services.bus_service.start(); }); - services.bus_service.start(); return messaging; }, };