-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite loop caused by two-way binding #398
Comments
I can reproduce this, but I'm not actually sure whether it's related to just the nested object setup. I removed the For debugging this (with both event handlers in place), it doesn't help that my browser freezes even with breakpoints inside both event handlers! I didn't even know that could happen. |
Actually, it looks like what's causing the problem is specifically the |
As far as I can tell, this is related to |
It must have something to do with the component structure - removing this line fixes the issue, too. |
Okay, yeah, looks like my solution doesn't help if the value being assigned is actually a normal object, there's still the same infinite loop. Checking for |
But in this case, you do not get the structure you originally planned, right? |
❓ |
I was just pointing that, when you remove that line, you are not rendering the exact/same structure and "sequence" of components. Although it fixes the issue, in a real scenario, if someone needs to render an specific sequence of components similarly to what you had done initially, removing a component would not be a solution. |
I only meant to point out that the infinite loop issue appears to depend on this specific component structure. |
Ah okay, I understood. |
I pushed a simpler/more specific reproduction to https://github.com/TehShrike/svelte-repro/tree/two-way-binding-infinite-loop .
When Now, like @Conduitry noticed, using some other falsey value instead of |
I wrote a test that I thought would be a straight copy of the reproduction above (which I tested in Chrome, Firefox, and Safari): TehShrike@f6f4c22 But the tests passed! I wasn't able to reproduce the infinite loop in the existing test structure. |
Using a custom component closure until sveltejs/svelte#398 is fixed
Man, that was a real Heisenbug. Think I've got it beat though — happily, the solution is straightforward and only adds bytes to component binding code: #407 |
prevent infinite loops caused by pathological component bindings
I have a root component with a piece of data.
This root component includes several different intermediate components.
Each of these intermediate components uses the same leaf component.
All of these components use two-way binding to share the same piece of data, from the root, all the way down to all the leaf components.
When the leaf component changes the data that is shared with two-way binding, an infinite loop occurs.
Reproduction is at https://github.com/TehShrike/svelte-repro/tree/two-way-binding-infinite-loop
To reproduce,
npm run build
index.html
fileThe issue only happens if both
IntermediateComponent
andEvenMoreIntermediate
are included inTestComponent
. Including multiple instances of justIntermediateComponent
or justEvenMoreIntermediate
does not cause the issue.The text was updated successfully, but these errors were encountered: