jackwener/OpenCLI · error · CommandExecutionError

archive wayback request failed: ${error?.message || error}

Error message

archive wayback request failed: ${error?.message || error}

What it means

The `archive wayback` command fetches `https://archive.org/wayback/available` to resolve the closest snapshot. This CommandExecutionError is thrown when the `fetch` itself rejects — the request never got an HTTP response — wrapping the underlying network error message. It is distinct from the HTTP-status error, which is reported separately as `archive wayback failed: HTTP <status>`.

Source

Thrown at clis/archive/wayback.js:55

                'Example: opencli archive wayback wikipedia.org',
            );
        }
        const timestamp = args.timestamp ? normalizeTimestamp(args.timestamp) : '';

        const apiUrl = new URL('https://archive.org/wayback/available');
        apiUrl.searchParams.set('url', target);
        if (timestamp) apiUrl.searchParams.set('timestamp', timestamp);

        let resp;
        try {
            resp = await fetch(apiUrl, {
                headers: {
                    'Accept': 'application/json',
                    'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)',
                },
            });
        } catch (error) {
            throw new CommandExecutionError(`archive wayback request failed: ${error?.message || error}`);
        }
        if (!resp.ok) {
            throw new CommandExecutionError(`archive wayback failed: HTTP ${resp.status}`);
        }
        let data;
        try {
            data = await resp.json();
        } catch (error) {
            throw new CommandExecutionError(`archive wayback returned malformed JSON: ${error?.message || error}`);
        }

        const snap = data?.archived_snapshots?.closest;
        if (!snap || !snap.available) {
            throw new EmptyResultError('archive wayback', `No Wayback snapshot for "${target}".`);
        }
        if (typeof snap.url !== 'string' || !snap.url || !/^\d{14}$/.test(String(snap.timestamp ?? ''))) {
            throw new CommandExecutionError('archive wayback returned malformed payload: closest snapshot is missing url/timestamp');
        }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the command — most fetch failures against archive.org are transient outages.
  2. Verify basic connectivity: `curl -I https://archive.org/wayback/available?url=example.com`.
  3. Check DNS/firewall/proxy configuration (HTTPS_PROXY, allowlists, Pi-hole block lists).
  4. Confirm TLS works from your runtime (update CA certificates / Node version) if you see certificate errors in the wrapped message.

Example fix

// before: fail hard on transient outage
await exec('opencli archive wayback example.com');
// after: retry once after a short delay
try {
  await exec('opencli archive wayback example.com');
} catch {
  await new Promise(r => setTimeout(r, 3000));
  await exec('opencli archive wayback example.com');
}
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight reachability check
const ok = await fetch('https://archive.org/wayback/available?url=example.com', { method: 'HEAD' })
  .then(() => true).catch(() => false);
if (!ok) console.warn('archive.org unreachable');

Try / catch

try {
  await exec('opencli archive wayback example.com');
} catch (e) {
  if (String(e.message).includes('archive wayback request failed')) {
    // network-level failure: retry with backoff, check proxy/DNS
  } else throw e;
}

Prevention

When it happens

Trigger: DNS resolution failure for archive.org, connection refused/timeout, TLS handshake errors, offline environment, IPv6 connectivity issues, or a proxy/firewall blocking archive.org — any condition where fetch throws instead of returning a response.

Common situations: Running in CI containers without egress to archive.org; DNS blockers (Pi-hole, corporate allowlists) rejecting archive.org; transient archive.org outages; misconfigured HTTP(S)_PROXY environment variables; Node versions lacking proper CA certificates for TLS.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/7af48544d8159876. Report an issue: GitHub.