Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
It is possible for
cleanNode
to be called recursively. This PR adds a simpleisCleaning
lock to ensure thatcleanNode
isn't called on the same node twice.Minimal example: https://playground.solidjs.com/anonymous/9f860e26-d0a3-476d-8b20-82ebff4763d7 (when you click "hide", you get a
Cannot read properties of null
error which comes fromcleanNode
being called twice on the same node).I believe this error is most likely to happen when your entire app isn't in Solid, but you're instead mounting several Solid roots inside an existing application. We have global state controlling which Solid roots and components to show, and a
syncState
function that reads from the global state and disposes/creates Solid roots based on that. If componentA
has aShow
that causes componentB
to be disposed, and componentB
has anonCleanup
that calls the globalsyncState
which disposes the entire Solid root thatA
is rendered in, thenA
will error in thecleanNode
function.I believe that this change should solve this problem, but I would love input on whether this change is reasonable at all, or whether it may have side effects that I haven't considered.
Thank you!
How did you test this change?
Would love advice on where you think it'd be best to add a test for this — didn't do it yet, because would first love input on whether this change makes sense.