{"record":{"id":"3515db9a1912a997","repo":"vercel/next.js","slug":"failed-to-download-url","errorCode":null,"errorMessage":"Failed to download: ${url}","messagePattern":"Failed to download: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/create-next-app/helpers/examples.ts","lineNumber":93,"sourceCode":"\nexport function existsInRepo(nameOrUrl: string): Promise<boolean> {\n  try {\n    const url = new URL(nameOrUrl)\n    return isUrlOk(url.href)\n  } catch {\n    return isUrlOk(\n      `https://api.github.com/repos/vercel/next.js/contents/examples/${encodeURIComponent(\n        nameOrUrl\n      )}`\n    )\n  }\n}\n\nasync function downloadTarStream(url: string) {\n  const res = await fetch(url)\n\n  if (!res.body) {\n    throw new Error(`Failed to download: ${url}`)\n  }\n\n  return Readable.fromWeb(res.body as import('stream/web').ReadableStream)\n}\n\nexport async function downloadAndExtractRepo(\n  root: string,\n  { username, name, branch, filePath }: RepoInfo\n) {\n  let rootPath: string | null = null\n  await pipeline(\n    await downloadTarStream(\n      `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`\n    ),\n    x({\n      cwd: root,\n      strip: filePath ? filePath.split('/').length + 1 : 1,\n      filter: (p: string) => {","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/create-next-app/helpers/examples.ts#L75-L111","documentation":"create-next-app's example downloader (`downloadTarStream`) throws when `fetch(url)` returns a response with no body (`res.body` is null/undefined). This happens before the tar extraction pipeline, meaning the GitHub codeload URL returned a non-streaming or empty response. The error includes the URL so the user can see which fetch failed.","triggerScenarios":"Running `create-next-app --example <name>` (or a custom repo URL) when the codeload.github.com tarball endpoint returns an empty body — e.g. a 404/500 served with no body, a redirected URL that lost the stream, or a network/proxy that stripped the body.","commonSituations":"Typo in the example name (resolves to a missing repo/branch); GitHub outage returning error pages without a body; corporate proxy/firewall that buffers or drops the stream; offline/air-gapped environment.","solutions":["Check the inlined URL in a browser/curl — if it 404s, fix the example name or repo/branch.","Verify network egress to codeload.github.com (proxy, firewall, VPN).","Retry during a GitHub outage; check https://www.githubstatus.com.","If behind a proxy, set HTTPS_PROXY and ensure it streams large tarballs correctly."],"exampleFix":"# verify the failing URL\ncurl -L -o /tmp/t.tar.gz 'https://codeload.github.com/vercel/next.js/tar.gz/canary'\n# if it 404s, use the correct branch/example name\nnpx create-next-app --example with-typescript my-app","handlingStrategy":"retry","validationCode":"// Pre-check the URL is reachable before streaming the tarball.\nimport { isUrlOk } from './examples'\nif (!(await isUrlOk(url.href))) {\n  throw new Error(`Example URL not reachable: ${url}`)\n}","typeGuard":"function isCodeloadUrl(u: string): boolean {\n  try { return new URL(u).hostname === 'codeload.github.com' } catch { return false }\n}","tryCatchPattern":"async function safeDownload(url: string, retries = 2) {\n  for (let i = 0; i <= retries; i++) {\n    try {\n      const res = await fetch(url)\n      if (res.body) return Readable.fromWeb(res.body)\n    } catch (e) { /* last iteration rethrows */ if (i === retries) throw e }\n  }\n  throw new Error(`Failed to download: ${url}`)\n}","preventionTips":["Validate the example/repo name with isUrlOk before downloading.","Retry transient network failures.","Configure proxy/egress for codeload.github.com in restricted environments."],"tags":["create-next-app","network","github","download","examples"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}