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
I believe this issue is a continuation of #15590. I was excited to see the fix for this issue, and immediately updated so I could remove some workarounds I had in place for my test suite. To my surprise, removing the workarounds caused the tests to fail.
I have JS module that takes a signal as input, feeds that signal into a mutable $derived internally, and exposes an onChange method to optimistically update the $derived. The module and tests look something like this:
Interestingly, removing the intermediate const source = $derived(options.source()) also fixes the issue:
- const source = $derived(options.source());- let value = $derived(source);+ let value = $derived(options.source());
At this point, this is mostly an annoyance in testing. Outside of this particular issue, though, we've been having persistent issues with $derived chains failing to update when expected. These issues have proved difficult to minimally reproduce, but I will file more issues if/when I'm able to boil them down
Reproduction
This was a bit tricky to reproduce in the REPL - it does not repro in the <script> tag of a component. I was, however, able to repro by placing the code in question inside a button's click handler:
Describe the bug
I believe this issue is a continuation of #15590. I was excited to see the fix for this issue, and immediately updated so I could remove some workarounds I had in place for my test suite. To my surprise, removing the workarounds caused the tests to fail.
I have JS module that takes a signal as input, feeds that signal into a mutable
$derived
internally, and exposes anonChange
method to optimistically update the$derived
. The module and tests look something like this:This test fails!
Just like in #15590, if I read
result.value
before callingonChange
. The test passes.+ void result.value; result.onChange("right"); expect(result.value).toBe("right");
Interestingly, removing the intermediate
const source = $derived(options.source())
also fixes the issue:At this point, this is mostly an annoyance in testing. Outside of this particular issue, though, we've been having persistent issues with
$derived
chains failing to update when expected. These issues have proved difficult to minimally reproduce, but I will file more issues if/when I'm able to boil them downReproduction
This was a bit tricky to reproduce in the REPL - it does not repro in the
<script>
tag of a component. I was, however, able to repro by placing the code in question inside a button's click handler:https://svelte.dev/playground/c88b99a5f9574364a587e1211a0b230a?version=5.25.10#H4sIAAAAAAAAE3VSXYucQBD8K81woAtG390POHL5BYG8xMDNaq83d2PPMNN6BvG_h9lZvRU2T0pVdRVWOQmSHYpSvKBTAzZAhqHrWZ41ikxclEYvyt-T4L82yAIgsuXo2drcD6g5YGfp8RFeG2Ik9qIUhwiWxrIy5MH1hB6KU0UVHXztlOXwzqqzxjFMtUPJ-GztT5aMM1yc6SDJC2ntNx-gW0r-7pPgUXFtyDMYqrWqP-AI6Q6OJ5gCtZDXQzjC1jxNPp2hNtlFaVFAT7XpOiQGNnBR40oMRjXRJR-k7jESETD0_U1Si2niVPvGi11INhpzbdr09cdosWZsoBJXUSUyaA3D03RnOr9eT-eKDsVXM3Q498yGYLp94nxyPQGj50MRqZPIBOPIomTX45z9Z7oHFW43fCy4GxPH60ix1G2ZoXhFrKT-Fb7lawONDN70rg6Spyb-cxtpRQBBdS3hXhTPdvvQAsCyc2w75BGOvEkDgNVlJfcBn28mDrl3tGjbJTXdLdAqGdZbgDmLzyU8Wyzn_bb6P5lgqfSnokaUF6k9zv8A1r21IW8DAAA=
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: