Skip to content

[BUG] On React without concurrent rendering, render prop produces ResizeObserver errors on Firefox #1136

Closed
@johannkor

Description

@johannkor

Bug description

When using React <18, or on React 18 and not using concurrent rendering (using ReactDOM.render() instead of createRoot().render(), use of the render prop produces errors on Firefox. This error is easily and consistently reproduced by rendering a list of elements which all use the same data-tooltip-id and data-tooltip-content. The error produced is:

ResizeObserver loop completed with undelivered notifications.

without a stack trace, which is caught by window.onerror handlers (and thus ends up in Sentry and other monitoring platforms).

Firefox also issues the following warning in the console:

Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content.

The app doesn't crash, but the error happens on almost every tooltip hover change (move cursor from element A to element B quickly), and thus produces thousands of errors per session per user on a tooltip-heavy site.

The error can of course be ignored with a regex as it does not crash the app or the tooltips, but clearly there is something wrong.

Version of Package

I have tested the following versions:

  • v5.25.0 - Reproduces
  • v5.24.0 - Reproduces
  • v5.19.0 - Reproduces
  • v5.15.0 - Reproduces
  • v5.12.0 - Reproduces
  • v5.10.1 - Cannot reproduce, or library is just so slow to change tooltips that it doesn't happen

To Reproduce

  1. Run the example

    import React from "react";
    import ReactDOM from "react-dom";
    import { Tooltip } from "react-tooltip";
    // using `disableStyleInjection="core"` to ensure it's not related to the recent
    // style injection features
    import "react-tooltip/dist/react-tooltip.css";
    
    const TOOLTIP_ID = "tooltip";
    
    function App() {
      return (
        <div className="App">
          <Tooltip
            disableStyleInjection="core"
            id={TOOLTIP_ID}
            render={({ content }) => <span>{content}</span>}
          />
    
          <div>
            {Array(50)
              .fill(0)
              .map((_, i) => (
                <div
                  key={i}
                  data-tooltip-id={TOOLTIP_ID}
                  data-tooltip-content={TOOLTIP_ID}
                >
                  row {i}
                </div>
              ))}
          </div>
        </div>
      );
    }
    
    ReactDOM.render(<App />, document.getElementById("root"));
  2. When the app is running, quickly swipe your cursor up and down the middle of the page

    • Swipe so that the cursor is over the tooltips, and swipe quickly enough that the tooltips don't have enough time to fully appear
    • Swipe from the top of the page to the bottom of the page quickly for maximum effectiveness
  3. Notice the error in the webpack dev server's error overlay which pops up

This bug also appears with normal usage (non-furious mouse swiping), but I found this to be the most effective way to reproduce it.

Expected behavior

I prefer this error not to occur, as it forces us to ignore the ResizeObserver error which hides other, unrelated ResizeObserver errors from us.

Desktop (please complete the following information if possible or delete this section):

  • OS: macOS
  • Browser: Firefox
  • Version: 102.0.1
  • Frameworks: React 16, React 17, React 18 (when not using concurrent mode)

Additional context
I have managed to reproduce this with Chrome in a larger application, but I have not been able to reproduce the error in the MVP above with Chrome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions