fix(updater): silence platform-missing errors + serialize latest.json - #31
Open
playmaker wants to merge 1 commit into
Open
fix(updater): silence platform-missing errors + serialize latest.json#31playmaker wants to merge 1 commit into
playmaker wants to merge 1 commit into
Conversation
Two related fixes for the Tauri auto-updater flow: - src/components/UpdateChecker.tsx: when the latest.json response doesn't carry an entry for the current platform (tauri-plugin-updater Error::TargetNotFound / Error::TargetsNotFound), treat it as 'no update available' instead of flashing a 'check failed' toast. IO, timeout, signature, and other errors still surface as before. - .github/workflows/release.yml + scripts/publish-update-json.cjs: the matrix build jobs each emit their own latest.json in parallel; last writer wins and platform entries get dropped. Add a post-build publish-json job that downloads every *.sig from the release, maps them to the expected platform keys, and overwrites latest.json deterministically. Co-Authored-By: Claude <noreply@anthropic.com>
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
macOS (Apple Silicon) users launching the desktop app see a "Update check failed" toast in the bottom-right corner on every startup, even though they already have the latest release installed. The toast body reads roughly:
There are two distinct bugs that compound to produce this UX:
Bug 1 — root cause: race in the release workflow
.github/workflows/release.ymlruns four targets in parallel (matrixover linux + macOS x64 + macOS aarch64 + Windows). Each tauri-action invocation is configured withincludeUpdaterJson: true, so every slot uploads its ownlatest.jsonto the same GitHub Release. Last writer wins.Concretely, the v0.40.0 release assets on disk include:
lovcode_0.40.0_aarch64.dmglovcode_aarch64.app.tar.gz+.siglovcode_0.40.0_x64_en-US.msi+_x64-setup.exe+ sigs_amd64.AppImage/.deb/.rpm+ sigslatest.jsoncontaining onlywindows-*andlinux-*keys (nodarwin-*)All seven
.sigfiles are present on the release — includinglovcode_aarch64.app.tar.gz.sigandlovcode_x64.app.tar.gz.sig. They just never made it intolatest.json. The updater client (tauri-plugin-updater 2.10) walks the candidate list{os}-{arch}-{installer},{os}-{arch}inget_urls(seeupdater.rs:581-597) and falls back toError::TargetsNotFoundwhen neither key is present — exactly the error the user sees at startup.Bug 2 — UX blows the symptom up
src/components/UpdateChecker.tsx:91-97catches the rejection fromcheck()and unconditionally storese.messageintostate.error, which then renders as a "Update Check Failed" toast. Even when the underlying cause is "this release doesn't ship your platform" (a perfectly normal condition during a partial rollout), the UI pretends something broke.Fix
1.
src/components/UpdateChecker.tsx— silence the platform-missing classAdd a tiny classifier that recognises only the two tauri-plugin-updater variants whose message text mentions
fallback platformsorwas not found in the response \platforms` object(Error::TargetNotFoundandError::TargetsNotFoundin 2.10). When one of those fires, transition tostage: "latest"instead ofstage: "error". The card'scanShowalready excludeslatest, so it never appears;StatusBarreadslatest` as "you are up to date" which matches reality.All other error classes — IO failures, timeouts, signature mismatches,
releaseNotFound, etc. — still surface the toast. Network and signature problems are exactly the kind of failure users need to see.2.
.github/workflows/release.yml+scripts/publish-update-json.cjs— deterministiclatest.jsonAdd a
publish-jsonjob that runs after the build matrix completes. It:release.outputs.tag; manual dispatch: frominputs.tag).*.sigalready on the release withgh release download --pattern '*.sig'.scripts/publish-update-json.cjs, which:versionfrompackage.json,pub_datefromgh release view $TAG --json publishedAt,platformsmap by matching each platform key to its known bundle filename using the signature contents pulled in step 2,latest.jsonand uploads it viagh release upload --clobber.The matrix slots keep their existing
includeUpdaterJson: trueand parallel builds — timing is unchanged. Thepublish-jsonjob then deterministically overwrites whatever one of them wrote last, eliminating the race.The platform → filename mapping in the script mirrors what tauri-action emits today:
11 keys total. Each
.tar.gzis reused twice (once bare, once with the-app/-nsisetc suffix) the way tauri-action does, so tauri-plugin-updater's{os}-{arch}-{installer}and{os}-{arch}candidates both resolve.Dry-run against the actual v0.40.0 release (
gh release download v0.40.0 --pattern '*.sig') produces exactly those 11 keys with the right URLs and signatures.Verification
node --check scripts/publish-update-json.cjspasses..sigfiles from v0.40.0 (already ongh release download) into the script's logic — output matches expectations.publish-jsonend-to-end; the workflow log will printlatest.json uploaded: keys=darwin-aarch64, darwin-aarch64-app, darwin-x86_64, darwin-x86_64-app, linux-x86_64, linux-x86_64-appimage, linux-x86_64-deb, linux-x86_64-rpm, windows-x86_64, windows-x86_64-msi, windows-x86_64-nsis.latest.jsonnow hasdarwin-aarch64+darwin-aarch64-app); meanwhile a real network failure or signature mismatch still produces the toast.Out of scope / not touched
tauri.conf.json,Cargo.toml,Cargo.lock.tauri-actionand uploads its own bundle +.sig; only the finallatest.jsonis centralised).downloadAndInstall's catch — its errors only happen after the user explicitly clicks "Update", never at startup.latest.jsonfor v0.40.0 on the existing release. The script can do this manually after merge (TAG=v0.40.0 GITHUB_REPOSITORY=lovstudio/lovcode node scripts/publish-update-json.cjs), but that's a separate operational fix and not part of this PR.🤖 Generated with Claude Code