vercel/next.js · error · Error
request failed with status ${res.status}
Error message
request failed with status ${res.status} What it means
Thrown by download-swc.ts when the HTTP fetch for a platform-specific SWC native binary (@next/swc-<triple>) returns a non-OK status from the package registry. Next.js downloads the SWC binary on demand when the bundled native binding is missing; a failing registry response (4xx/5xx) aborts extraction so a corrupt/empty binary is never installed.
Source
Thrown at packages/next/src/lib/download-swc.ts:48
Log.info(`Downloading swc package ${pkgName}... to ${cacheDirectory}`)
await fs.promises.mkdir(cacheDirectory, { recursive: true })
const tempFile = path.join(
cacheDirectory,
`${tarFileName}.temp-${Date.now()}`
)
const registry = getRegistry()
const downloadUrl = `${registry}${pkgName}/-/${tarFileName}`
await fetch(downloadUrl).then((res) => {
const { ok, body } = res
if (!ok || !body) {
Log.error(`Failed to download swc package from ${downloadUrl}`)
}
if (!ok) {
throw new Error(`request failed with status ${res.status}`)
}
if (!body) {
throw new Error('request failed with empty body')
}
const cacheWriteStream = fs.createWriteStream(tempFile)
return body.pipeTo(
new WritableStream({
write(chunk) {
return new Promise<void>((resolve, reject) =>
cacheWriteStream.write(chunk, (error) => {
if (error) {
reject(error)
return
}
resolve()
})
)View on GitHub (pinned to 0ae8c72462)
Solutions
- Check network/registry reachability: `npm ping` and verify the @next/swc-<triple> package exists on your configured registry.
- Ensure .npmrc auth tokens are set for private registries and that the registry proxies the full @next scope including @next/swc-*.
- Pre-install the matching SWC binary manually: `npm install @next/swc-<os>-<arch>-<libc>` so download is skipped.
- If offline, copy the SWC binary from another machine into packages/next-swc/native/ or set NEXT_SWC_PATH to a cached tarball.
Example fix
# before: missing binary, registry returns 404 pnpm build # after: install the platform binary explicitly pnpm add @next/swc-linux-x64-gnu pnpm build
Defensive patterns
Strategy: retry
Validate before calling
// Pre-flight: confirm the SWC package is reachable on the registry
async function swcBinaryReachable(triple: string, version: string): Promise<boolean> {
const r = await fetch(`https://registry.npmjs.org/@next/swc-${triple}/${version}`)
return r.ok
} Try / catch
async function downloadWithRetry(url: string, attempts = 3) {
for (let i = 0; i < attempts; i++) {
const r = await fetch(url)
if (r.ok && r.body) return r
if (i === attempts - 1) throw new Error(`request failed with status ${r.status}`)
await new Promise((res) => setTimeout(res, 500 * (i + 1)))
}
throw new Error('unreachable')
} Prevention
- Pre-install the @next/swc-<triple> package to skip the on-demand download.
- Ensure .npmrc auth and registry config cover the @next scope in restricted networks.
- Add a pre-build registry reachability check in CI.
- Keep a cached tarball (NEXT_SWC_PATH) for offline builds.
When it happens
Trigger: Occurs during dev/build when the native .node binding is absent and extractBinary() fetches the tarball. res.ok is false — the registry returned an error status (404 for unknown triple, 401/403 for private registry auth, 5xx for outage, 451 for blocked region).
Common situations: Custom npm registry (Verdaccio, Artifactory, Nexus) that lacks the @next/swc-* package; offline or corporate-proxy environments blocking registry.npmjs.org; a typo'd platform triple; npmrc auth misconfiguration; or a transient npm registry outage. Also seen when a private registry mirrors only some scopes.
Related errors
- request failed with empty body
- Failed to get registry from "${pkgManager}".
- Failed to fetch ${url}
- Command failed: ${command} ${args.join(' ')} (exit ${code})
- Missing ${NEXT_BIN}. Build Next.js first (pnpm --filter=next
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/d72c7d4c3861eb06.
Report an issue: GitHub.