{"record":{"id":"d2ce066bd579cf0b","repo":"withastro/astro","slug":"failed-to-fetch-latest-astro-version","errorCode":null,"errorMessage":"Failed to fetch latest Astro version","messagePattern":"Failed to fetch latest Astro version","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/astro/src/core/dev/update-check.ts","lineNumber":25,"sourceCode":"\nlet _latestVersion: string | undefined = undefined;\n\nexport async function fetchLatestAstroVersion(\n\tpreferences: AstroPreferences | undefined,\n): Promise<string> {\n\tif (_latestVersion) {\n\t\treturn _latestVersion;\n\t}\n\n\tconst packageJson = await fetchPackageJson(undefined, 'astro', 'latest');\n\tif (packageJson instanceof Error) {\n\t\tthrow packageJson;\n\t}\n\n\tconst version = packageJson?.version;\n\n\tif (!version) {\n\t\tthrow new Error('Failed to fetch latest Astro version');\n\t}\n\n\tif (preferences) {\n\t\tawait preferences.set('_variables.lastUpdateCheck', Date.now(), { reloadServer: false });\n\t}\n\n\t_latestVersion = version;\n\treturn version;\n}\n\nexport async function shouldCheckForUpdates(preferences: AstroPreferences): Promise<boolean> {\n\tif (ci.isCI) {\n\t\treturn false;\n\t}\n\n\tconst timeSinceLastCheck = Date.now() - (await preferences.get('_variables.lastUpdateCheck'));\n\tconst hasCheckUpdatesEnabled = await preferences.get('checkUpdates.enabled');\n","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/dev/update-check.ts#L7-L43","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nastro dev\n\n# after (skip update check)\nASTRO_DISABLE_UPDATE_CHECK=true astro dev","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await fetchLatestAstroVersion(prefs); } catch (e) { /* non-fatal; skip update notification */ }","preventionTips":["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."],"tags":["network","update-check","registry","non-blocking"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}