Repository navigation
Release unmounted reflex_xy chart views after React clears DOM refs - #554
Conversation
…548) XYChart.jsx re-read outerRef.current?.id during effect cleanup to find its window.__xy_views key. React nulls DOM refs before passive effect cleanup, so cleanup fell back to the mount id and left the destroyed, id-keyed view registered (e.g. the showcase board after the small-multiples toggle). Capture the registry key once per mount and reuse it for registration and removal, deleting the entry only while it still holds this mount's view. The Socket.IO connection-order gate now detaches object and callback refs before cleanup, matching React, and asserts the registry empties for named and anonymous mounts. The browser smoke asserts exact 13 -> 15 -> 13 view counts across the cond toggle, with the board released.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 30 seconds. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
[Low impact] The PR appears safe to merge. SummaryThe PR removes unmounted chart views using a saved registry key without deleting a newer view under the same key.
Reviews (3) · Last reviewed commit: "Bound the smoke's registry settle wait; ..." · Reviewed by Greptile |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
- Socket gate: static src mounts (named and anonymous) release their views after refs detach, and an older mount's cleanup leaves a newer view under the same key registered. Both fail against an unconditional delete or a ref re-read at cleanup. - Browser smoke: wait for the view registry to settle before reading the baseline used by the exact cond-toggle counts.
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
- Settle the view registry with one in-page poll (1.5 s quiet, 30 s limit) so a stalled page cannot extend the wait past its budget; name the durations in comments. - Spec: the transport-stays-connected claim applies to live mounts; static src mounts never open the data plane.
Fixes #548.
Root cause
XYChart.jsxregistered each view inwindow.__xy_viewsunderouterRef.current?.id || mid, then re-read that expression during effect cleanup. React detaches DOM refs (object refs nulled, callback refs called withnull) before passive effect cleanup, so cleanup fell back to the mount id and thedeletemissed the id-keyed entry. Destroyed views (e.g. the showcaseboardafter the small-multiples toggle) stayed in the registry.Fix
releaseViewKey(key, view)deletes the entry only while it still holds this mount's view, so a later mount reusing the same id is never evicted by an earlier mount's cleanup.Tests
tests/reflex_socket_connection.cjs(run viatests/test_reflex_socket_connection.py): the stub now detaches object and callback refs before running cleanup, matching React's order. All five connection-order variants assert exact registry keys and an empty registry after the last unmount. New test covers anonymous + named mounts releasing their views while the shared app transport stays connected. Before the fix, six tests failed; after it, all seven pass.scripts/reflex_ws_smoke.py: the cond/foreach step now asserts exact counts 13 → 15 → 13 across the toggle and back, thatboardleaves the registry, and that no registered view is destroyed. Verified it times out on the old JSX and passes with the fix against the running demo (prod, single port).tests/reflex_adapter+ socket gate: 252 passed. pre-commit,ruff check,ruff format --checkclean.Not covered: client-side navigation to
/kindsand back — the smoke loads/kindswith a full page navigation.Docs
spec/design/reflex-integration.md: new "Unmount releases the view" paragraph.news/548.bugfix.md.Generated by Claude Code