Skip to content

Commit

Permalink
Add explicit error handling for ResizeObserver errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathonherbert committed Mar 4, 2024
1 parent d0d2eda commit ddee475
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fronts-client/integration/fixtures/error-handling.js
Original file line number Diff line number Diff line change
@@ -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();
}
});
};
2 changes: 2 additions & 0 deletions fronts-client/integration/tests/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ddee475

Please sign in to comment.