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
(Edge case) Elements are not being removed when promise resolves in onbeforeremove #1881
Comments
Thanks for the report @porsager Here's an instrumented repro The element that remains is an extra child that is added before the previous one has been removed... Not sure there's a lot we can do about it. Thinking needed. Edit: bad link |
Here's the bug reproduced in such a way that requires no clicks |
Here's what I suspect: it's a race condition between the promise resolution and the subsequent render adding the item, confusing the diff algorithm with inconsistent state. Here's a more stripped-down, synchronous repro using Here's what I am observing:
|
Short-listing this for a v2 fix. The repro still works |
Found the issue, and it's two-part: Mithril's throwing an exception because of a race condition, and Mithril incorrectly relies on its It boils down to this:
What this means is that we need to remove |
I'm kind of leaning towards doing this to fix it:
All this would be limited to the removal logic, but it'd mean I'd have to pretty much rewrite the whole thing. This should help avoid a few potential issues with a naïve solution:
|
Does this continue to repro with v2? |
Unfortunately yes. |
Wow.. Good job @isiahmeadows ! |
@porsager It was a bit involved trying to figure out why the fuzzer suddenly started failing. Tried to do it in a way that didn't create a bunch of perf issues, too. Sadly, the bundle is now about 9.7kB. Stupid bug fixes... 😉😄 |
Reopening because my fix for this caused other breakage and I need to figure out how to fix this without breaking
|
Re-closing. Issue appears unrelated. |
I can't really explain the series of events causing this, but here is a reproducible case which will leave elements in the dom if the button is doubleclicked while the red box is visible.
(Double click the toggle button)
Repro setup
Maybe someone else with a clear set of eyes can spot / describe it better?
The real use case was a loading icon being animated inside a parent component and at certain timings would result in the parent component not being removed.
The text was updated successfully, but these errors were encountered: