fix(plugins): refetch the registry manifest before install/update (#1380)#1402
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.
Problem
A user updated to v0.44.0 and got "Plugin Installation Failed" when installing a plugin; quitting, reopening, and reinstalling fixed it. The "restart fixes it" signature points at stale in-memory state, not a bad binary.
Root cause
Registry installs resolve the binary against a manifest that can be stale:
RegistryClientloads the on-disk cached manifest into memory at launch, and that cache (plus the ETag) survives an app update.installMissingPlugin, Browse install, manual update, reconciliation) usedfetchManifest()without forcing a refresh. On a 304, a CDN-cached copy, or a network blip,fallbackToCacheOrFailkeeps the stale in-memory manifest, so the install runs against the pre-update plugin list.fetchManifest(forceRefresh:)only dropped theIf-None-Matchheader; it never set a cache policy, so URLSession's local cache could still return a stale body.A restart "fixes" it only because it eventually triggers a fresh fetch.
Fix
RegistryClient.fetchManifest(forceRefresh:)now setsrequest.cachePolicy = .reloadIgnoringLocalCacheData, so a forced refresh genuinely bypasses the local URL cache (the documented AppKit/Foundation way; no cache-busting query hacks).installFromRegistryandupdateFromRegistryrefetch the manifest and re-resolve the plugin by id before validating compatibility, viaRegistryClient.refreshedPlugin(matching:). Every install/update path (connect-to-install, Browse, manual update, reconciliation) now resolves against the current manifest. Offline still falls back to the cached manifest, where the existing strict version + checksum checks turn a mismatch into a clear error instead of a wrong install.Tests
makeManifestRequest(forceRefresh:)is extracted and unit-tested: forced refresh sets the reload cache policy and sends noIf-None-Match.Logic-only, no new user-facing strings.