Skip to content
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

fix: StoredValue and Resource panic during cleanup #2583

Merged
merged 1 commit into from May 11, 2024

Conversation

luxalpa
Copy link
Contributor

@luxalpa luxalpa commented May 8, 2024

If the value inside a StoredValue implements the drop trait, and that drop causes another read, update or dispose on another StoredValue, we'd get a cryptic panic with already mutably borrowed: BorrowError.
I encountered this issue with a StoredValue<Disposer> with the disposer type returned by as_child_of_current_owner(). Because the Disposer cleans up a reactive sub-scope on Drop, it will try to mutably borrow Runtime::stored_values while it is still mutably borrowed by the function that drops it.

@gbj
Copy link
Collaborator

gbj commented May 11, 2024

Oh, wow. This is one of those very awkward examples where the scoping of when the BorrowMut handle gets dropped makes a real difference. Nice catch.

@gbj gbj merged commit 7f4a292 into leptos-rs:main May 11, 2024
57 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants