jackwener/OpenCLI · error · CommandExecutionError

${label} request failed

Error message

${label} request failed

What it means

eutilsFetch performs the HTTP GET to NCBI E-utilities. When fetch itself rejects (network unreachable, DNS failure, connection refused, TLS error), it rethrows as CommandExecutionError '<label> request failed' with the underlying error message as detail. Called by the xml, esearch, and result code paths.

Source

Thrown at clis/pubmed/utils.js:103

    const delayMs = process.env.NCBI_API_KEY ? 110 : 360;
    const now = Date.now();
    const waitMs = Math.max(0, lastRequestAt + delayMs - now);
    if (waitMs > 0) {
        await new Promise(resolve => setTimeout(resolve, waitMs));
    }
    lastRequestAt = Date.now();
}

export async function eutilsFetch(tool, params = {}, { retmode = 'json', label = 'PubMed E-utilities' } = {}) {
    const url = buildEutilsUrl(tool, { ...params, retmode });
    await waitForRateLimit();
    let response;
    try {
        response = await fetch(url);
    }
    catch (error) {
        const detail = error instanceof Error ? error.message : String(error);
        throw new CommandExecutionError(`${label} request failed`, detail);
    }
    if (!response.ok) {
        throw new CommandExecutionError(`${label} HTTP ${response.status}`, 'Check NCBI availability, request parameters, and optional NCBI_API_KEY.');
    }
    if (retmode === 'xml') {
        return response.text();
    }
    try {
        const json = await response.json();
        assertNoEutilsError(json, label);
        return json;
    }
    catch (error) {
        if (error instanceof CommandExecutionError) {
            throw error;
        }
        const detail = error instanceof Error ? error.message : String(error);
        throw new CommandExecutionError(`${label} returned invalid JSON`, detail);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify connectivity: curl -v https://eutils.ncbi.nlm.nih.gov/entrez/eutils/einfo.fcgi
  2. Set HTTPS_PROXY/HTTP_PROXY (and NO_PROXY) if your network requires a proxy
  3. Retry after a short backoff — failures are often transient
  4. Check NCBI service status and network/firewall rules for eutils.ncbi.nlm.nih.gov

Example fix

// before
HTTPS_PROXY=  # proxy required by network but unset
pubmed search 'cattle genomics'
// after
export HTTPS_PROXY=http://proxy.corp.example:8080
pubmed search 'cattle genomics'
Defensive patterns

Strategy: retry

Validate before calling

// pre-check connectivity before running the command
await fetch('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/einfo.fcgi')
  .then(r => { if (!r.ok) throw new Error('eutils unreachable: ' + r.status); });

Try / catch

async function withRetry(fn, attempts = 3) {
  for (let i = 1; i <= attempts; i++) {
    try { return await fn(); }
    catch (err) {
      if (err instanceof CommandExecutionError && /request failed/.test(err.message) && i < attempts) {
        await new Promise(r => setTimeout(r, 2 ** i * 500));
        continue;
      }
      throw err;
    }
  }
}
// usage: withRetry(() => pubmedSearch(query))

Prevention

When it happens

Trigger: Any pubmed command while offline, with broken DNS, through a blocking proxy/firewall, or when NCBI drops the connection mid-request.

Common situations: Corporate proxies blocking ncbi.nlm.nih.gov, VPN down, missing HTTPS_PROXY for Node's fetch, transient NCBI outage, IPv6 connectivity issues.

Related errors


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