Repository navigation
Shorten update-check interval and add foreground/network triggers - #231
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Update checks previously ran on a 24-hour wall-clock cadence, so a compatible hub upgrade could go unnoticed for a day, and server switches relied on the startup check plus the 426 trigger. This change tightens the cadence and wires the checks into the events that actually signal "something changed": server switches, returning to the foreground, and network recovery.
Changes
Scheduling (
packages/api/src/updates/update-checker.ts)visibilitychange→ visible,focus,online), throttled to 5 minutes based on the most recent attempt or successful check. Failed attempts also count toward the throttle, so a flapping network can't produce request storms; manual checks bypass it.initUpdateChecks()now returns a stop function that clears the timers, the sync-status subscription, the base-URL subscription, and all DOM/window listeners. Stopping also cancels checks waiting on a server switch.Robustness across server switches
/healthis requested with an explicitbaseURLsnapshot and a 15s timeout.Installer reuse
preparedVersion); a version with no published package yet is retried on the next check. Registering a different shell resets the cache.API client (
packages/api/src/api/client.ts)onApiBaseUrlChange(listener)subscription.setApiBaseUrlnow notifies only on an actual value change.Docs
spec.mdand issue 03 to reflect the new cadence and triggers; added issue 07 documenting the delivered behavior and acceptance criteria.Testing
update-checker.test.tswas extended from 12 to 211 lines of coverage, including the API-client subscription. All 55 update-check, verdict, and API-client tests pass, covering:focus,visibilitychange,online) and background events being ignored,Real-device download and install acceptance remains tracked by issues 05 and 06.