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
hono/jsx/dom: attributes and effects are lost when Suspense children suspend again #5562
It becomes <p class="page">b</p>. Child stays the same component, so unmount is not logged.
What do you see instead?
It becomes <p>b</p> (the class is gone).
unmount is logged, but mount is not logged again.
Additional information
This happens on every page change when a router loads page data with use().
What seems to cause it: when the fallback is shown, the old children are kept in pC, but they are also removed from the DOM by removeNode, and their effect cleanups run. When they come back, the same nodes are reused. Since pP equals the current props, unchanged attributes are not set on the newly created elements (around line 618 of render.ts).
The root cause appears to be a lifecycle mismatch in hono/jsx/dom. When Suspense falls back, applyNodeObject() sends the previous subtree through removeNode(), which cleans up effects and refs and removes DOM elements. On restoration, the virtual nodes retain their previous props and effect dependencies, so unchanged attributes are skipped and effects are never mounted again.
I suggest treating suspension as a temporary hide rather than an unmount: preserve the committed DOM subtree, component state, refs, and effects while rendering the fallback separately. Restore and reconcile the same nodes when the promise resolves, reserving removeNode() for genuine unmounts. Regression tests should cover repeated suspensions, DOM identity, attributes, effect cleanup, and stale promise resolutions.
I’m happy to implement and validate this fix. @yusukebe, could you assign #5562 to me? Since external PRs may be disabled, would you be open to me implementing it on my fork and providing a tested branch or commit for you to pull/cherry-pick?
Hono-kun here, an AI maintainer, posting on behalf of @yusukebe.
Thanks for the report and for asking before changing the core. We went with option 1: all props are set again on an element that is created again, and the effects of a removed node start fresh. So unmount is called and then mount is called again. We did not choose option 2 because it changes the core of the renderer. #5642 uses your test as the base, and you are a co-author.
Activity
harshitsharmaaaa commentedon Nov 1, 2026
@yusukebe
The root cause appears to be a lifecycle mismatch in
hono/jsx/dom. When Suspense falls back,applyNodeObject()sends the previous subtree throughremoveNode(), which cleans up effects and refs and removes DOM elements. On restoration, the virtual nodes retain their previous props and effect dependencies, so unchanged attributes are skipped and effects are never mounted again.I suggest treating suspension as a temporary hide rather than an unmount: preserve the committed DOM subtree, component state, refs, and effects while rendering the fallback separately. Restore and reconcile the same nodes when the promise resolves, reserving
removeNode()for genuine unmounts. Regression tests should cover repeated suspensions, DOM identity, attributes, effect cleanup, and stale promise resolutions.I’m happy to implement and validate this fix. @yusukebe, could you assign #5562 to me? Since external PRs may be disabled, would you be open to me implementing it on my fork and providing a tested branch or commit for you to pull/cherry-pick?
hono-kun commentedon Nov 16, 2026
Hono-kun here, an AI maintainer, posting on behalf of @yusukebe.
Thanks for the report and for asking before changing the core. We went with option 1: all props are set again on an element that is created again, and the effects of a removed node start fresh. So
unmountis called and thenmountis called again. We did not choose option 2 because it changes the core of the renderer. #5642 uses your test as the base, and you are a co-author.