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
Describe the bug / To Reproduce
We encountered a weird edge case in our app where where one of the stores didn't trigger any updates in a child component sometimes.
There are multiple steps necessary for this bug to happen, so I'll try to explain it in a step-by-step way, otherwise it gets unreadable.
Bind which will set displayPanel to true when $x != undefined and show Subscr
Subscr which subscribes to $x in code within a reactive block $:
And we have a global store x initialized to undefined
When clicking on start:
store x is set to "1"
Bind will notice this and set displayPanel to true
App will notice this and render the {#if} Block
Subscr will render with the store value correctly set and show E: 1
store x is set to undefinded
Subscr will not notice this update, even though $x is in the recative block. In fact the reactive block does not get executed at all (check the console output).
Only setting $x to something that is not undefined and then setting it back to undefined the Subscr component will notice each update again.
You can see in the console log that the first set to undefined does not get noticed by the Subscr component.
Set to e
update 1
Set to undef
Set to e
update 2
Set to undef
update undefined
From my debugging it seems like Subscr has a stale value of x when it gets created but $x has the new value. When then setting x to undefined the update will not execute since the old value already is undefined. But I might be wrong here.
Also when using the $x variable in the html this problem does not occour and the store gets updated correctly. (I've added a comment in the Subscr to mark this)
Expected behavior
The reactive statement should correctly be executed with the store change.
Information about your Svelte project:
Your browser and the version: Firefox 81.0.2 (64-bit)
Your operating system: Windows 10 Education
Svelte version 3.29.0
Using rollup (but should not relevant for this case)
Severity
Low to Medium:
The bug itself can be easily work around by adding the store somewhere in the html part, but finding and debugging the cause is a nightmare.
The text was updated successfully, but these errors were encountered:
Describe the bug / To Reproduce
We encountered a weird edge case in our app where where one of the stores didn't trigger any updates in a child component sometimes.
There are multiple steps necessary for this bug to happen, so I'll try to explain it in a step-by-step way, otherwise it gets unreadable.
The step-by-step is tied to this REPL:
https://svelte.dev/repl/ae73276603ff41048ac558daae06bf4a?version=3.29.0
In the basic outline
App
has two childs:Bind
which will setdisplayPanel
totrue
when$x != undefined
and showSubscr
Subscr
which subscribes to$x
in code within a reactive block$:
x
initialized toundefined
When clicking on start:
x
is set to "1"Bind
will notice this and setdisplayPanel
to trueApp
will notice this and render the{#if}
BlockSubscr
will render with the store value correctly set and showE: 1
x
is set toundefinded
Subscr
will not notice this update, even though$x
is in the recative block. In fact the reactive block does not get executed at all (check the console output).$x
to something that is notundefined
and then setting it back toundefined
theSubscr
component will notice each update again.You can see in the console log that the first set to undefined does not get noticed by the
Subscr
component.From my debugging it seems like
Subscr
has a stale value ofx
when it gets created but$x
has the new value. When then settingx
toundefined
the update will not execute since the old value already isundefined
. But I might be wrong here.Also when using the $x variable in the html this problem does not occour and the store gets updated correctly. (I've added a comment in the
Subscr
to mark this)Expected behavior
The reactive statement should correctly be executed with the store change.
Information about your Svelte project:
Severity
Low to Medium:
The bug itself can be easily work around by adding the store somewhere in the html part, but finding and debugging the cause is a nightmare.
The text was updated successfully, but these errors were encountered: