{"record":{"id":"4df3f85c04cc0c12","repo":"FuelLabs/fuels-ts","slug":"failed-to-fetch-latest-fuels-version","errorCode":null,"errorMessage":"Failed to fetch latest fuels version.","messagePattern":"Failed to fetch latest fuels version\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/fuels/src/cli/utils/getLatestFuelsVersion.ts","lineNumber":18,"sourceCode":"import { checkAndLoadCache, saveToCache } from './fuelsVersionCache';\n\nexport const getLatestFuelsVersion = async (): Promise<string | undefined> => {\n  const cachedVersion = checkAndLoadCache();\n  if (cachedVersion) {\n    return cachedVersion;\n  }\n\n  const data: { version: string } | null = await Promise.race([\n    new Promise((_, reject) => {\n      // eslint-disable-next-line prefer-promise-reject-errors\n      setTimeout(() => reject(null), 3000);\n    }),\n    fetch('https://registry.npmjs.org/fuels/latest').then((response) => response.json()),\n  ]);\n\n  if (!data) {\n    throw new Error('Failed to fetch latest fuels version.');\n  }\n\n  const version = data.version as string;\n\n  saveToCache(version);\n\n  return version;\n};\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/fuels/src/cli/utils/getLatestFuelsVersion.ts#L1-L27","documentation":"A plain Error (not a FuelError) thrown by getLatestFuelsVersion when the npm registry fetch loses a 3-second race against a setTimeout and resolves to null. The function only throws when the timeout wins; a successful fetch returns the version. The result is used for version-bump hints, so this failure is non-fatal to builds and should be caught by callers.","triggerScenarios":"Calling getLatestFuelsVersion when the network is slow, offline, behind a restrictive proxy, or when registry.npmjs.org is unreachable within 3s.","commonSituations":"Air-gapped CI, corporate firewall/proxy blocking npm registry, slow mobile link, transient npm outage.","solutions":["Ensure outbound HTTPS to registry.npmjs.org is permitted from the build environment.","Configure HTTP(S)_PROXY if behind a corporate proxy.","Wrap the call in try-catch and treat undefined as 'no version hint'.","Pre-warm the version cache (fuelsVersionCache) in environments with intermittent connectivity."],"exampleFix":"// before\nconst latest = await getLatestFuelsVersion();\n// after — tolerate the hint being unavailable\nlet latest: string | undefined;\ntry {\n  latest = await getLatestFuelsVersion();\n} catch {\n  latest = undefined;\n}","handlingStrategy":"fallback","validationCode":"import { checkAndLoadCache } from './fuelsVersionCache';\nconst safeGetLatest = async (): Promise<string | undefined> => checkAndLoadCache() ?? undefined;","typeGuard":null,"tryCatchPattern":"let latest: string | undefined;\ntry {\n  latest = await getLatestFuelsVersion();\n} catch {\n  latest = undefined; // version hint is non-essential\n}","preventionTips":["Treat the latest-version hint as optional; never block builds on it.","Whitelist registry.npmjs.org in CI network policy.","Cache the version locally to avoid repeated fetches."],"tags":["network","cli","npm","version","timeout","non-fatal"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}