Hmbown/CodeWhale · error · Error

Too many redirects while checking

Error message

Too many redirects while checking ${url}

What it means

requestStatus performs a HEAD (or GET) HTTP status check on a release asset URL, following redirects recursively with a counter. More than 10 redirects indicates a redirect loop or misconfigured CDN, so it aborts instead of following forever.

Solutions

  1. Check the asset URL for a redirect loop (curl -IL <url>)
  2. Verify any custom download mirror/proxy configuration
  3. Retry later if it is a transient GitHub/CDN issue
  4. Use the direct github.com release URL instead of a mirror
Defensive patterns

Strategy: retry

Validate before calling

const { execSync } = require("child_process");
const hops = execSync(`curl -sIL -o /dev/null -w '%{num_redirects}' ${url}`).toString();
if (Number(hops) > 10) throw new Error(`Redirect loop for ${url}`);

Try / catch

try { await verifyAsset(url, label); } catch (e) { if (/Too many redirects/.test(e.message)) { await new Promise(r => setTimeout(r, 2000)); return verifyAsset(url, label); } throw e; }

Prevention

When it happens

Trigger: verifyAsset → requestStatus on a GitHub releases/CDN URL that returns a redirect chain longer than 10 hops, or a redirect loop (A→B→A).

Common situations: Misconfigured release mirror or custom CODEWHALE download URL; GitHub CDN outages; corporate proxies bouncing requests between hosts.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/c5ca5a29a580f306. Report an issue: GitHub.

Appendix: source

Thrown at npm/codewhale/scripts/verify-release-assets.js:67

function assertPackageVersionMatchesBinaryVersion(version) {
  if (packageVersionMatchesBinaryVersion(version)) {
    return;
  }
  if (process.env.CODEWHALE_ALLOW_NPM_BINARY_MISMATCH === "1") {
    console.log(
      `npm package version ${pkg.version} points at binary release ${version} (allowed packaging-only mismatch).`,
    );
    return;
  }
  throw new Error(
    `npm package version ${pkg.version} does not match codewhaleBinaryVersion ${version}. ` +
      "Set CODEWHALE_ALLOW_NPM_BINARY_MISMATCH=1 only for an intentional packaging-only npm release.",
  );
}

function requestStatus(url, method = "HEAD", redirects = 0) {
  if (redirects > 10) {
    throw new Error(`Too many redirects while checking ${url}`);
  }
  const client = url.startsWith("https:") ? https : http;
  return new Promise((resolve, reject) => {
    const req = client.request(
      url,
      {
        method,
        headers: {
          "User-Agent": "codewhale-npm-release-check",
        },
      },
      (res) => {
        const status = res.statusCode || 0;
        const location = res.headers.location;
        res.resume();
        if (status >= 300 && status < 400 && location) {
          const next = new URL(location, url).toString();
          resolve(requestStatus(next, method, redirects + 1));

View on GitHub (pinned to 433685b202)