https://github.com/xpl/r3f-leak
R3F leaks the last root's state via module-level variables in the render loop
https://github.com/xpl/r3f-leak
Last synced: 17 days ago
JSON representation
R3F leaks the last root's state via module-level variables in the render loop
- Host: GitHub
- URL: https://github.com/xpl/r3f-leak
- Owner: xpl
- License: mit
- Created: 2026-04-30T21:30:37.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-05-11T21:53:45.000Z (about 2 months ago)
- Last Synced: 2026-05-11T23:38:12.294Z (about 2 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# How to run
```
npm i
npm run dev
```
# What happens
R3F leaks the last root's state via module-level variables in the render loop.
After all Canvas components unmount and _roots is empty, the module-scoped `state`, `subscribers`, and `subscription` variables in the loop/update functions still reference the last rendered root's store state — preventing GC of the entire fiber tree and any bridged context values.
Repro: click the button, wait for all 16 cycles, force garbage collection in DevTools, observe last value stays "alive".

# Bug report / PR fix
https://github.com/pmndrs/react-three-fiber/pull/3747