-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
Intermediate memo does not recompute #3252
Comments
Thanks for the repro, I noticed this or a similar bug last week but had trouble tracking it down. This is a nice minimal example. |
Ah you know what, this is actually just the opposite of #3158 which you opened a while ago. Now, rather than deadlocking, having a ReadLock on a memo while it needs to be updated is failing silently. Using I am not sure that it is possible to refactor the way memos are structured such that the value and the reactive machinery are separate from one another, because whether a memo needs to update or not depends on its value. So taking a read lock on a memo, and holding that during other reactive operations, is quite tricky. Any suggestions? Perhaps the answer is just a better answer to errors here, like a console warning instead of either panicking or failing silently? |
An error or a warning would be a very welcome improvement indeed. 👍 As for what I'm doing: In my case, I can also rework my code to use So there's a part of me that very much hopes for a world where the |
Another tidbit worth mentioning: I have quite a lot of memos that always recompute their value when their inputs change. And they never bother comparing the new value with the old value, because they cannot be the same. |
That's fine, this is just not a memo and should be implemented differently. In fact, because of the trait-based approach in On the other hand, I'm not sure what purpose a memo is serving here? If the memos are defined such that they are never the same value, it's a bunch of reactive-graph overhead for no real reason, as far as I can tell. |
I used a memo, because it seemed like the most straightforward way of doing "[...] will only run once per change, no matter how many times you access its value.", while also having laziness. The only memo part that I don't need is the equality check. I suppose I could write my own primitive, although I'm not entirely sure where to start. |
I started implementing my own primitive, and here are my notes so far
|
I'm going to try to refactor the memo to have a more granular lock than I do suspect that that'll be a bigger change, and that it might not fix everything. I'll have to write a few unit tests to make sure it's at least less error-prone after that change. |
Describe the bug
I have set up a reactive graph with "source => memo 1 => memo 2" and "memo1, memo2 => effect". When I change the source, then the first memo gets recomputed, the effect gets updated, but the second memo stays the same.
Leptos Dependencies
To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should have printed
Additional context
I also have a demo project that can run in a browser environment
leptos-testos.zip
The demo project can also be run in a browser environment by doing
and then serving
index.html
with a HTTP server and opening it in a browser.I originally thought that it was a wasm-bindgen-futures specific bug, but it turned out that I just didn't manage to properly reproduce it on desktop.
The text was updated successfully, but these errors were encountered: