Findings No. 26
An effect cleanup that re-reads reactive state can unbind the wrong element
A teardown that re-read a reactive containerRef removed listeners from whatever the ref held at teardown, not the element the effect bound: a latent leak. Capture the target in the effect body, or go declarative.
An effect cleanup that re-reads reactive state at teardown can act on a different object than the one the effect set up. Woof Editor's editor component added listeners to the element in a reactive containerRef, and the cleanup removed them from whatever containerRef held at teardown time, which after a re-bind is not necessarily the element the listener was added to: a latent leak with no symptom until the ref actually changes.
The repo's fix was to delete the hazard class entirely: the document listener became a declarative <svelte:document onselectionchange> and the scroll listener became an onscroll attribute, so the framework owns paired setup and teardown. Where an imperative effect is genuinely needed, the rule is to capture the target in the effect body and close over it, never re-read reactive state in the cleanup.
Receipt: woof-editor CHANGELOG 0.2.0 (Changed: "$effect ladder cleanups", which names the latent teardown bug).