Skip to content

Commit e22ea0c

Browse files
ealmloffjkelleyrtp
andauthored
Fix repeated subscription to dropped scope leak (#3569)
* Fix repeated subscription to dropped scope leak --------- Co-authored-by: Jonathan Kelley <[email protected]>
1 parent c7951b7 commit e22ea0c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/core/src/reactive_context.rs

+14
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,17 @@ struct Inner {
311311
// The scope that this reactive context is associated with
312312
scope: Option<ScopeId>,
313313
}
314+
315+
impl Drop for Inner {
316+
fn drop(&mut self) {
317+
let Some(self_) = self.self_.take() else {
318+
return;
319+
};
320+
321+
for subscriber in std::mem::take(&mut self.subscribers) {
322+
if let Ok(mut subscriber) = subscriber.0.lock() {
323+
subscriber.remove(&self_);
324+
}
325+
}
326+
}
327+
}

0 commit comments

Comments
 (0)