-
Notifications
You must be signed in to change notification settings - Fork 644
fix: Update SnapController state when SnapsRegistry changes
#3828
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: Update SnapController state when SnapsRegistry changes
#3828
Conversation
SnapController state when SnapsRegistry changes
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3828 +/- ##
==========================================
- Coverage 98.40% 98.39% -0.01%
==========================================
Files 430 430
Lines 12448 12453 +5
Branches 1933 1933
==========================================
+ Hits 12249 12253 +4
- Misses 199 200 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
| }); | ||
| }, | ||
| ({ database }) => database, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing subscription cleanup in destroy causes memory leak
Medium Severity
The new SnapsRegistry:stateChange subscription uses an anonymous callback function, and no reference is saved. This makes it impossible to unsubscribe in the destroy() method. Other subscriptions (like ExecutionService:unhandledError) follow a pattern where callbacks are bound and stored as class properties so they can be properly cleaned up. This missing cleanup means the destroyed controller remains referenced by the messenger, causing a memory leak and potentially triggering handlers on destroyed instances.


Trigger registry updating logic in the
SnapControllerevery time theSnapsRegistrydatabase changes. Previously we would only do this whenupdateRegistrywas called. This will make it easier to add polling logic toSnapsRegistryand ensures that theSnapControlleris up to date if the registry is updated by other means.Note
Medium Risk
Adds event-driven registry processing for snap blocking/unblocking and preinstalled updates, which can affect snap availability and update behavior if the new subscription misfires or races with state updates. Changes are localized but touch security-relevant blocklist enforcement paths.
Overview
SnapController now stays in sync with registry changes. It subscribes to
SnapsRegistry:stateChangeand runs the existing registry-processing logic (block/unblock installed snaps and optionally auto-update preinstalled snaps) whenever the registry database updates.updateRegistry()is narrowed to only triggerSnapsRegistry:update, with the blocking/unblocking + preinstalled-update work moved into a new private#handleRegistryUpdate()invoked by the registry event (with error logging). Tests and test utilities are updated soMockSnapsRegistryself-registers action handlers on the messenger and emitsSnapsRegistry:stateChangeonupdate, and affected tests now construct the registry with the messenger and wait for state propagation where needed.Written by Cursor Bugbot for commit 81b2f56. This will update automatically on new commits. Configure here.