withastro/astro · warning · Error
Failed to fetch latest Astro version
Error message
Failed to fetch latest Astro version
What it means
`fetchLatestAstroVersion` queries the npm registry for the `astro` package's `latest` dist-tag; if the returned JSON has no `version` field it throws 'Failed to fetch latest Astro version'. (If `fetchPackageJson` itself returned an `Error`, that is re-thrown first.) This powers the periodic update-check notification, not the build itself.
Source
Thrown at packages/astro/src/core/dev/update-check.ts:25
let _latestVersion: string | undefined = undefined;
export async function fetchLatestAstroVersion(
preferences: AstroPreferences | undefined,
): Promise<string> {
if (_latestVersion) {
return _latestVersion;
}
const packageJson = await fetchPackageJson(undefined, 'astro', 'latest');
if (packageJson instanceof Error) {
throw packageJson;
}
const version = packageJson?.version;
if (!version) {
throw new Error('Failed to fetch latest Astro version');
}
if (preferences) {
await preferences.set('_variables.lastUpdateCheck', Date.now(), { reloadServer: false });
}
_latestVersion = version;
return version;
}
export async function shouldCheckForUpdates(preferences: AstroPreferences): Promise<boolean> {
if (ci.isCI) {
return false;
}
const timeSinceLastCheck = Date.now() - (await preferences.get('_variables.lastUpdateCheck'));
const hasCheckUpdatesEnabled = await preferences.get('checkUpdates.enabled');
View on GitHub (pinned to d081033d5f)
Solutions
- Disable the update check: set `ASTRO_DISABLE_UPDATE_CHECK=true` in the environment, or run `astro preferences disable checkUpdates`.
- Verify connectivity to the npm registry and that the mirror returns standard `package.json` metadata.
- If using a custom registry, ensure it serves the full `version` field for the `astro` package.
Example fix
# before astro dev # after (skip update check) ASTRO_DISABLE_UPDATE_CHECK=true astro dev
Defensive patterns
Strategy: fallback
Try / catch
try { await fetchLatestAstroVersion(prefs); } catch (e) { /* non-fatal; skip update notification */ } Prevention
- Set ASTRO_DISABLE_UPDATE_CHECK=true in CI or offline environments.
- Use a standard npm registry or a faithful mirror.
- Wrap update-check usage so its failure never blocks the dev server.
When it happens
Trigger: The update-check runs (interactive, non-CI, `checkUpdates.enabled` true, 12-day interval elapsed) and the npm registry responds without a `version` field — e.g., a malformed/empty response, registry mirror returning a non-standard payload, or a transient proxy issue stripping the field.
Common situations: Behind a corporate proxy/artifactory that returns a truncated registry response; npm registry outage returning HTML; an internal mirror with a different JSON shape; offline cache returning stale/empty data.
Related errors
- Unable to fetch ${integration}. Does the package exist?
- CannotFetchFontFile
- Template ${tmpl} does not exist!
- Unable to download template ${tmpl}
- the prerender server responded ${response.status} ${response
AI-assisted analysis of withastro/astro@d081033d5f (2026-08-12).
Data as JSON: /api/errors/d2ce066bd579cf0b.
Report an issue: GitHub.