fix(web): break effect_update_depth_exceeded in HomePage health-poll diff#40
Merged
Conversation
…diff The F12 breach-detection effect read prevHealthSnapshot via detectBreaches() AND wrote to it (`prevHealthSnapshot = next`) in the same effect. Since prevHealthSnapshot was declared `$state(...)`, Svelte 5 (correctly) flagged the cycle as effect_update_depth_exceeded and stopped re-running the effect. prevHealthSnapshot is a "previous tick" memo — no template reads it, no other effect depends on it. Reactivity is unnecessary. Demoting it to a plain `let` keeps the value alive across effect re-runs through the component closure scope without making it a reactive signal. Verify: - svelte-check 0/0/436. - npm test 68/68 (no test impact — pure-function notify lib unchanged). - Manual: dev server loads with no console errors. Refs: PRD-007 RFC-006
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hotfix for runtime error reported by user after F12 merge:
Root cause
HomePage.svelte:130$effect for breach detection:prevHealthSnapshotviadetectBreaches(prevHealthSnapshot, next, ...)prevHealthSnapshot = nextat the bottomBoth on the same
$state(...)signal → Svelte 5 (correctly) detects the cycle and abort-loops the effect.Fix
prevHealthSnapshotis a "previous tick" memo — no template reads it, no other effect depends on it. Reactivity is unnecessary; the value lives across re-runs via the component's closure scope. Demoted to plainlet.Verify
npx svelte-check— 0/0/436.npm test— 68/68 (no test impact; pure-function notify lib unchanged).Why $state was wrong here
In Svelte 5 runes,
$statecreates a reactive signal. Any effect that reads + writes the same signal triggers a cycle. For "memoized previous value" between successive runs of one effect, a plainletsurvives in closure scope without becoming reactive — that's the idiomatic pattern.Refs:
PRD-007RFC-006🤖 Generated with Claude Code