From cc8e69d97c5bb4dd3885ba601171ccf3824d2c8e Mon Sep 17 00:00:00 2001 From: "Arthur Detroux (ard)" Date: Wed, 21 Sep 2022 09:43:09 +0000 Subject: [PATCH] [FIX] website: gracefully reject events Prior to this commit, the WysiwygAdapter would crash with a TB if an event reached the wysiwyg_adapter when the websiteRootInstance was no longer accessible (in case of a PageReload while an event in the mutex is still trying to fire events). Note that normally, events should not be sent when the websiteRootInstance is gone as the editor should be destroyed. But since "widgets_start_request" triggers also implement a "onFailure", it seems right to use that in such case. closes odoo/odoo#101687 X-original-commit: 0cc206f94151e2da646064e265e14a341daff58a Signed-off-by: Quentin Smetz (qsm) --- .../src/components/wysiwyg_adapter/wysiwyg_adapter.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js index 0accc487c96..9e19f1ccb48 100644 --- a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js +++ b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js @@ -427,6 +427,16 @@ export class WysiwygAdapterComponent extends ComponentAdapter { */ _websiteRootEvent(type, eventData = {}) { const websiteRootInstance = this.websiteService.websiteRootInstance; + // If the websiteRootInstance is gone but an event still tries to reach it + // prevent a traceback by denying the event. + // TODO we should investigate if this is normal the websiteRootInstance + // is being accessed while being dead following a wysiwyg adapter event. + if (!websiteRootInstance) { + if (eventData.onFailure) { + return eventData.onFailure(); + } + return false; + } return websiteRootInstance.trigger_up(type, {...eventData}); } _preventDefault(e) {