You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: RSC dev: every server rebuild keeps the previous server bundle alive (react-server-dom-rspack's async hook and console wrappers) #16597
In dev, loadBundle() evaluates the server bundle again after each rebuild, react-server-dom-rspack included. Each evaluation of react-server-dom-rspack/server.node (development build) enables a new async_hooks hook and wraps 13 console methods around the previous wrappers. Neither is ever undone, and both close over that evaluation's module scope, so every server bundle stays alive for the life of the dev server.
With rsbuild-plugin-rsc's own examples/server, unchanged, editing src/Todos.tsx 30 times (heap after GC):
Disabling the previous hook on each createHook() call is not enough (31/31 bundles still alive: the console wrappers hold them). Also putting back console's original methods keeps it flat:
Both come from React's Flight dev code: createHook({...}).enable() in initAsyncDebugInfo and the module-level patchConsole(console, …) calls. React's own Jest setup works around the hook part by disabling the previous hook in a createHook mock (setupTests.js).
Suggested fix: make both installs idempotent per process in react-server-dom-rspack (keep the previous hook and console's original methods under a global symbol; disable the hook and wrap the originals on re-evaluation).
In a larger app (TanStack Start with RSC on Rsbuild) this is 7–12 MB per edit, and every enabled hook runs for each new async resource in the process.
Activity