shadcn-ui/ui · error · RegistrySourceFileError

FETCH_ERROR

FETCH_ERROR

Error message

Failed to read GitHub source file "${filePath}" from ${formatGitHubSource(address)}.

What it means

Thrown by fetchGitHubSourceFile in the try/catch around fetchWithProxy: the network request to raw.githubusercontent.com itself threw (connection refused, DNS failure, TLS error, timeout, or proxy error). GitHub ref resolution already succeeded; only the raw-file fetch failed. The error is wrapped as RegistrySourceFileError with the offending url, source, and filePath in context.

Source

Thrown at packages/shadcn/src/registry/github.ts:187

    },
  }
}

async function fetchGitHubSourceFile(
  url: string,
  filePath: string,
  address: GitHubSource
) {
  let response: Response
  try {
    response = await fetchWithProxy(url, {
      headers: new Headers({
        "Accept-Encoding": "identity",
        "User-Agent": "shadcn",
      }),
    })
  } catch (error) {
    throw new RegistrySourceFileError(filePath, error, {
      message: `Failed to read GitHub source file "${filePath}" from ${formatGitHubSource(
        address
      )}.`,
      context: {
        reason: "github-source-file",
        url,
        source: formatGitHubSource(address),
        filePath,
      },
      suggestion:
        "GitHub ref resolution succeeded, but the CLI could not fetch from raw.githubusercontent.com. Check that raw.githubusercontent.com is accessible from this network.",
    })
  }

  if (!response.ok) {
    throw new RegistrySourceFileError(filePath, undefined, {
      message: `Failed to read GitHub source file "${filePath}" from ${formatGitHubSource(
        address

View on GitHub (pinned to efac598707)

Solutions

  1. Verify raw.githubusercontent.com is reachable: curl -I the URL from the same environment.
  2. Correct or clear the HTTPS_PROXY/HTTP_PROXY env vars if the configured proxy is unreachable.
  3. Whitelist raw.githubusercontent.com on the firewall/proxy.
  4. Retry once network is restored; ref resolution results are cached so only the file fetch is repeated.
Defensive patterns

Strategy: retry

Validate before calling

async function rawGithubReachable(url: string) {
  const res = await fetch(url, { method: "HEAD" });
  if (!res.ok && res.status >= 500) throw new Error(`raw.githubusercontent.com unhealthy (${res.status})`);
  return true;
}
// probe reachability before kicking off a build that resolves GitHub sources

Type guard

function isNetworkError(err: unknown): boolean {
  return err instanceof RegistrySourceFileError && err.context?.reason === "github-source-file" && err.context?.statusCode === undefined;
}

Try / catch

for (const wait of [0, 2000, 8000]) {
  try {
    return await fetchGitHubRegistryItem(address);
  } catch (err) {
    if (err instanceof RegistrySourceFileError && err.context?.reason === "github-source-file" && err.context?.statusCode === undefined && wait < 8000) {
      await new Promise(r => setTimeout(r, wait));
      continue;
    }
    throw err;
  }
}

Prevention

When it happens

Trigger: Corporate firewall or egress proxy blocks raw.githubusercontent.com, DNS resolution fails in a sandboxed CI, TLS interception breaks the handshake, or the network is offline after the (cached) ref resolution step.

Common situations: CI runners behind a restrictive proxy, air-gapped environments, intermittent connectivity, or a proxy env var (HTTPS_PROXY) pointing at an unreachable proxy.

Related errors


AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12). Data as JSON: /api/errors/406e522158c9f176. Report an issue: GitHub.