Skip to content

feat: add requestPeriodicUpdate method to SnapRegistryController#4043

Open
Mrtenz wants to merge 2 commits into
mainfrom
mrtenz/snap-registry-periodic-update
Open

feat: add requestPeriodicUpdate method to SnapRegistryController#4043
Mrtenz wants to merge 2 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 around existing fetch/update paths; default thresholds and requestUpdate behavior are unchanged for messenger callers.

Overview
Adds a periodicFetchThreshold constructor option (default 4 hours) and a public requestPeriodicUpdate() on SnapRegistryController for callers that want occasional registry refreshes (e.g. on wallet unlock) without hitting the network on every trigger.

requestPeriodicUpdate no-ops when lastUpdated is within the periodic window—publishing registryUpdated with false and skipping fetch—otherwise delegates to requestUpdate, which still uses the existing 5-minute recent-fetch guard inside #update. #wasRecentlyFetched now accepts an optional threshold so the periodic path can reuse the same logic.

Unit tests cover first fetch, skip within threshold, and refetch when stale. The method is not registered on the messenger (unlike requestUpdate); consumers call it on the controller instance directly.

Reviewed by Cursor Bugbot for commit 085669c. 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 (085669c).

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`.
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.

1 participant