remix-run / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
30k stars 2.53k forks source link

HMR causes infinite render loop with nested Awaits #9759

Open lsthornt opened 4 months ago

lsthornt commented 4 months ago

Reproduction

  1. Visit this StackBlitz
  2. Open developer console while Stackblitz loads (you will be observing console)
  3. Once Stackblitz loads its browser, make any chance to a project file to trigger HMR
  4. Observe: render count is incremented infinitely in the console

System Info

From Stackblitz --

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @remix-run/dev: * => 2.10.2 
    @remix-run/node: * => 2.10.2 
    @remix-run/react: * => 2.10.2 
    @remix-run/serve: * => 2.10.2 
    vite: ^5.1.0 => 5.3.3

Used Package Manager

npm

Expected Behavior

Actual Behavior

An HMR causes innerComponent to re-render infinitely

lsthornt commented 3 months ago

Repeatedly running into this, and having to find workarounds.

In digging around, it does feel related to #7809 and #7392 (useMemo not working as expected deferred loader data)