Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not throw ResizeObserver loop limit exceeded errors #40

Closed
Maximaximum opened this issue Sep 29, 2023 · 3 comments · Fixed by #41
Closed

Do not throw ResizeObserver loop limit exceeded errors #40

Maximaximum opened this issue Sep 29, 2023 · 3 comments · Fixed by #41

Comments

@Maximaximum
Copy link

Even though the README.md explicitly mentions that the ResizeObserver loop limits exceeded error can be ignored, this does not seem to be a proper behavior. The error should not be thrown at all instead. This can be easily achieved by wrapping the ResizeObserver constructor callback with a requestAnimationFrame() call.

The problem with current implementation is that we have a global error handler. The handler ensures that the app fails on any unhandled exception, and sends the error to the Sentry endpoint so that we can monitor all the unhandled errors that occur while using the app.

While in the handler we could check if an error message contains a “ResizeObserver” string, or has exactly a specific error message string, and ignore it in such case, this is not a best practice scalable and manageable solution.

Besides, we might want to be informed on ResizeObserver errors that occur in other places in the app, but not in the container query polyfill.

@Marshal27
Copy link
Owner

@Maximaximum Ultimately the ResizeObserver implementation, along with the readme, came from the source repo this was forked from. I simply added shadow DOM support to the polyfill, which was unfortunately not merged in before the original repo went in to maintenance mode, and this fork was created at the recommendation of devknoll on the GoogleChromeLabs team.

With that said, I appreciate you pointing this out, and I will take a closer look.

@Marshal27
Copy link
Owner

Adding this here for posterity.

Avoid ResizeObserver loop limit exceeded. The issues surfaces on Chrome version >=64.

since ResizeObserver seems to be firing the callback immediately after observe() is called, this causes an infinite loop.

Reference: WICG/resize-observer#38

Eventually the error may be turned into a warning via w3c Issue#5023.. in lieu of having that as a viable solution, I am working on the recommended fix mentioned by the OP.

@Marshal27
Copy link
Owner

Marshal27 commented Sep 29, 2023

@Maximaximum Please run v1.1.8 through its paces, and feel free to re-open this issue if the problem has not been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants