From 86399fc7858c7307309740bdedb8fc62ab122c2e Mon Sep 17 00:00:00 2001 From: MerlinGuillaume Date: Thu, 8 Jun 2023 12:47:40 +0000 Subject: [PATCH] [FIX] web: ignore incorrect Safari errors Steps to reproduce: (on Safari only) 1. Install Email Marketing and Mass mailing on sale orders 2. Open Email Marketing and try to open 'Our last promotions, just for you!' 3. An error is thrown Solution: Ignore errors raised in Safari Problem: Error "ResizeObserver loop completed with undelivered notifications." is raised by the ResizeObserver in `mailing_mailing_view_form_full_width.js`. However in Safari (and desipte the ResizeObserver flow being exactly the same than in other browsers), the error message is "Script error." so we are not able to correctly discard it in the error listener of `error_service.js` opw-3339673 closes odoo/odoo#130389 X-original-commit: d00144d1198131ba7c68466b514518ca056ceef0 Signed-off-by: Francois Georis (fge) Signed-off-by: Guillaume Merlin (megu) --- addons/web/static/src/core/browser/feature_detection.js | 9 +++++++++ addons/web/static/src/core/errors/error_service.js | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/core/browser/feature_detection.js b/addons/web/static/src/core/browser/feature_detection.js index 2aec3e0b60f..85740a1d88b 100644 --- a/addons/web/static/src/core/browser/feature_detection.js +++ b/addons/web/static/src/core/browser/feature_detection.js @@ -17,6 +17,15 @@ export function isBrowserFirefox() { return /Firefox/i.test(browser.navigator.userAgent); } +/** + * true if the browser is based on Safari (Safari, Epiphany) + * + * @returns {boolean} + */ +export function isBrowserSafari() { + return !isBrowserChrome() && browser.navigator.userAgent.includes("Safari"); +} + export function isAndroid() { return /Android/i.test(browser.navigator.userAgent); } diff --git a/addons/web/static/src/core/errors/error_service.js b/addons/web/static/src/core/errors/error_service.js index 12099acf7be..71aca19045d 100644 --- a/addons/web/static/src/core/errors/error_service.js +++ b/addons/web/static/src/core/errors/error_service.js @@ -4,8 +4,7 @@ import { browser } from "../browser/browser"; import { _t } from "@web/core/l10n/translation"; import { registry } from "../registry"; import { completeUncaughtError, getErrorTechnicalName } from "./error_utils"; -import { isIOS } from "@web/core/browser/feature_detection"; -import { session } from "@web/session"; +import { isIOS, isBrowserSafari } from "@web/core/browser/feature_detection"; /** * Uncaught Errors have 4 properties: @@ -86,7 +85,7 @@ export const errorService = { } let uncaughtError; if (!filename && !lineno && !colno) { - if (isIOS() && session.is_frontend && odoo.debug !== "assets") { + if ((isIOS() || isBrowserSafari()) && odoo.debug !== "assets") { // In Safari 16.4+ (as of Jun 14th 2023), an error occurs // when going back and forward through the browser when the // cache is enabled. A feedback has been reported but in the