Skip to content

feat: add requestPeriodicUpdate method to SnapRegistryController#4043

Merged
Mrtenz merged 5 commits into
mainfrom
mrtenz/snap-registry-periodic-update
Jun 24, 2026
Merged

feat: add requestPeriodicUpdate method to SnapRegistryController#4043
Mrtenz merged 5 commits into
mainfrom
mrtenz/snap-registry-periodic-update

Conversation

@Mrtenz

@Mrtenz Mrtenz commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

Adds a periodicFetchThreshold option (default: 4 hours) and a public requestPeriodicUpdate method to SnapRegistryController.

The new method is similar to requestUpdate, but skips the update if the registry was fetched within the periodic threshold. This is useful for callers that want to keep the registry reasonably up to date on a longer interval (e.g., on wallet unlock) without triggering a fetch on every call.


Note

Low Risk
Additive API and config with tests; existing requestUpdate behavior is unchanged.

Overview
Adds requestPeriodicUpdate on SnapRegistryController so callers can refresh the snap allowlist registry on a longer cadence (default 4 hours) without hitting the existing 5-minute “recent fetch” guard used by requestUpdate.

The controller gains a configurable periodicFetchThreshold and refactors #wasRecentlyFetched to accept an optional threshold. When the last fetch is still inside that window, requestPeriodicUpdate no-ops and publishes registryUpdated with false; otherwise it delegates to requestUpdate. Messenger action types and unit tests cover first fetch, skip-within-threshold, and fetch-after-threshold behavior.

Reviewed by Cursor Bugbot for commit c9343e1. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds a `periodicFetchThreshold` option (default 4 hours) and a
`requestPeriodicUpdate` method that skips the update when the registry
was fetched within that threshold, reducing unnecessary network requests
while still keeping the database reasonably up to date.
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.58%. Comparing base (9467ef5) to head (c9343e1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4043   +/-   ##
=======================================
  Coverage   98.58%   98.58%           
=======================================
  Files         425      425           
  Lines       12364    12371    +7     
  Branches     1948     1950    +2     
=======================================
+ Hits        12189    12196    +7     
  Misses        175      175           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Mrtenz Mrtenz marked this pull request as ready for review June 23, 2026 15:22
@Mrtenz Mrtenz requested a review from a team as a code owner June 23, 2026 15:22

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6554437. Configure here.

Ensures callers can observe when `requestPeriodicUpdate` skips the fetch
because the registry was recently fetched, consistent with the other
early-exit paths in `#update`.
Adds the method to `MESSENGER_EXPOSED_METHODS`, and updates tests to call
through the messenger.
Comment thread packages/snaps-controllers/src/snaps/registry/SnapRegistryController.ts Outdated
…roller.ts

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
@Mrtenz Mrtenz requested a review from FrederikBolding June 24, 2026 09:18
@Mrtenz Mrtenz requested a review from FrederikBolding June 24, 2026 09:22
@Mrtenz Mrtenz enabled auto-merge June 24, 2026 09:23
@Mrtenz Mrtenz added this pull request to the merge queue Jun 24, 2026
Merged via the queue into main with commit fb62fb0 Jun 24, 2026
131 checks passed
@Mrtenz Mrtenz deleted the mrtenz/snap-registry-periodic-update branch June 24, 2026 09:29
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.

2 participants