mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-06 00:47:52 +00:00
fix(fleet): add Docker Hub fallback for version detection on private repos (#463)
* fix(fleet): add Docker Hub fallback for version detection on private repos The GitHub Releases API returns 404 for private repos, causing the latest version fetch to silently fail and fall back to the gateway's own version (defeating the update detection fix from PR #454). Now tries GitHub first, then falls back to Docker Hub tags API which is always public. Adds console.warn logging on fetch failures per Directive 7. * ci: trigger CI re-run
This commit is contained in:
@@ -72,6 +72,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
* **fleet:** fix false "Update available" on remote nodes whose `api_url` has a trailing slash, causing `fetchRemoteMeta` to construct a double-slash URL that fails silently
|
||||
* **fleet:** detect updates via GitHub Releases API instead of comparing against the gateway's own version. Previously, the local node could never appear outdated because it compared its version to itself. The Recheck button now invalidates the 30-minute version cache and fetches the actual latest release.
|
||||
* **fleet:** add Docker Hub tags API as fallback for version detection when the GitHub repo is private. The GitHub Releases API returns 404 for private repos, causing version detection to silently fail and fall back to the gateway's own version.
|
||||
|
||||
## [0.41.1](https://github.com/AnsoCode/Sencho/compare/v0.41.0...v0.41.1) (2026-04-08)
|
||||
|
||||
|
||||
+36
-9
@@ -1241,17 +1241,44 @@ let latestVersionCache: { version: string; fetchedAt: number } | null = null;
|
||||
let latestVersionInflight: Promise<string | null> | null = null;
|
||||
const LATEST_VERSION_CACHE_TTL = 30 * 60 * 1000; // 30 minutes
|
||||
|
||||
async function fetchFromGitHub(): Promise<string | null> {
|
||||
const res = await fetch('https://api.github.com/repos/AnsoCode/Sencho/releases/latest', {
|
||||
headers: { Accept: 'application/vnd.github+json', 'User-Agent': 'Sencho' },
|
||||
signal: AbortSignal.timeout(10000),
|
||||
});
|
||||
if (!res.ok) return null;
|
||||
const data = await res.json() as { tag_name?: string };
|
||||
const tag = data.tag_name?.replace(/^v/, '') ?? null;
|
||||
return tag && semver.valid(tag) ? tag : null;
|
||||
}
|
||||
|
||||
async function fetchFromDockerHub(): Promise<string | null> {
|
||||
const res = await fetch(
|
||||
'https://hub.docker.com/v2/repositories/saelix/sencho/tags/?page_size=50&ordering=last_updated',
|
||||
{ headers: { 'User-Agent': 'Sencho' }, signal: AbortSignal.timeout(10000) },
|
||||
);
|
||||
if (!res.ok) return null;
|
||||
const data = await res.json() as { results?: { name: string }[] };
|
||||
const tags = (data.results ?? [])
|
||||
.map(t => t.name)
|
||||
.filter(n => semver.valid(n));
|
||||
if (tags.length === 0) return null;
|
||||
tags.sort(semver.rcompare);
|
||||
return tags[0];
|
||||
}
|
||||
|
||||
async function fetchLatestSenchoVersion(): Promise<string | null> {
|
||||
try {
|
||||
const res = await fetch('https://api.github.com/repos/AnsoCode/Sencho/releases/latest', {
|
||||
headers: { Accept: 'application/vnd.github+json', 'User-Agent': 'Sencho' },
|
||||
signal: AbortSignal.timeout(10000),
|
||||
});
|
||||
if (!res.ok) return null;
|
||||
const data = await res.json() as { tag_name?: string };
|
||||
const tag = data.tag_name?.replace(/^v/, '') ?? null;
|
||||
return tag && semver.valid(tag) ? tag : null;
|
||||
} catch {
|
||||
const gh = await fetchFromGitHub();
|
||||
if (gh) return gh;
|
||||
} catch (err) {
|
||||
// GitHub API fails for private repos or rate limits; try Docker Hub
|
||||
console.warn('[VersionCheck] GitHub fetch failed:', (err as Error).message);
|
||||
}
|
||||
try {
|
||||
return await fetchFromDockerHub();
|
||||
} catch (err) {
|
||||
console.warn('[VersionCheck] Docker Hub fetch failed:', (err as Error).message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user