From ddee4756350f292682a995b399cad903f28f4a8f Mon Sep 17 00:00:00 2001 From: Jonathon Herbert Date: Mon, 4 Mar 2024 14:49:52 +0000 Subject: [PATCH] Add explicit error handling for ResizeObserver errors --- .../integration/fixtures/error-handling.js | 15 +++++++++++++++ fronts-client/integration/tests/main.spec.js | 2 ++ 2 files changed, 17 insertions(+) create mode 100644 fronts-client/integration/fixtures/error-handling.js diff --git a/fronts-client/integration/fixtures/error-handling.js b/fronts-client/integration/fixtures/error-handling.js new file mode 100644 index 00000000000..26cebcf3838 --- /dev/null +++ b/fronts-client/integration/fixtures/error-handling.js @@ -0,0 +1,15 @@ +/** + * These errors are sometimes thrown by the browser and appear to be beyond our control. + * They don't stop execution, so ignore them. + */ +export const explicitErrorHandler = () => { + window.addEventListener('error', (e) => { + if ( + e.message === + 'ResizeObserver loop completed with undelivered notifications.' || + e.message === 'ResizeObserver loop limit exceeded' + ) { + e.stopImmediatePropagation(); + } + }); +}; diff --git a/fronts-client/integration/tests/main.spec.js b/fronts-client/integration/tests/main.spec.js index d905a0bc04b..8de68cd06e3 100644 --- a/fronts-client/integration/tests/main.spec.js +++ b/fronts-client/integration/tests/main.spec.js @@ -26,8 +26,10 @@ import { } from '../selectors'; import setup from '../server/setup'; import teardown from '../server/teardown'; +import { explicitErrorHandler } from '../fixtures/error-handling'; fixture`Fronts edit`.page`http://localhost:3456/v2/editorial` + .clientScripts({ content: `(${explicitErrorHandler.toString()})()` }) .before(setup) .after(teardown);