pacocoursey / cmdk

Fast, unstyled command menu React component.
https://cmdk.paco.me
MIT License
9.42k stars 266 forks source link

ResizeObserver loop limit exceeded Sentry flood #64

Closed Simek closed 1 year ago

Simek commented 1 year ago

Hello, lately we have switched from Algolia Docsearch UI to custom one build upon the CMDK menu on http://docs.expo.dev.

After few days on production I have spotted that we started to receive around 1k Sentry events a day related to the ResizeObserver logic used inside CMDK ("ResizeObserver loop limit exceeded"):

I have tried to reproduce this problem locally, but without a success. From the reports it looks like this mostly affect desktop users using Chrome or Edge, on macOS and Windows.

You can find our implementation here:

Any hint on how to reproduce or fix that problem would be appreciated.

Simek commented 1 year ago

After a bit of digging it looks like this problem is related to https://github.com/WICG/resize-observer/issues/38 and wrapping the ResizeObserver logic with window.requestAnimationFrame should prevent the infinite loops.