jackwener/OpenCLI · error · CommandExecutionError
DuckDuckGo suggest request failed: ${err instanceof Error ?
Error message
DuckDuckGo suggest request failed: ${err instanceof Error ? err.message : String(err)} What it means
The DuckDuckGo suggest command fetches https://duckduckgo.com/ac/ to get autocomplete phrases. If the fetch itself rejects (network unreachable, DNS failure, TLS error, aborted request), the error is wrapped in a CommandExecutionError whose message embeds the original error's message. This distinguishes transport-level failures from HTTP status errors and JSON parse failures.
Source
Thrown at clis/duckduckgo/suggest.js:26
access: 'read',
description: 'DuckDuckGo search suggestions',
domain: 'duckduckgo.com',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'keyword', positional: true, required: true, help: 'Search query prefix' },
{ name: 'limit', type: 'int', default: 8, help: 'Max number of suggestions' },
],
columns: ['phrase'],
func: async (kwargs) => {
const limit = requireBoundedInteger(kwargs.limit, 8, 1, 20, '--limit');
const keyword = encodeURIComponent(requireSearchQuery(kwargs.keyword));
const url = `https://duckduckgo.com/ac/?q=${keyword}&type=list`;
let resp;
try {
resp = await fetch(url);
} catch (err) {
throw new CommandExecutionError(`DuckDuckGo suggest request failed: ${err instanceof Error ? err.message : String(err)}`);
}
if (!resp.ok) {
throw new CommandExecutionError(`DuckDuckGo suggest returned HTTP ${resp.status}`);
}
let data;
try {
data = await resp.json();
} catch (err) {
throw new CommandExecutionError(`DuckDuckGo suggest returned malformed JSON: ${err?.message ?? err}`);
}
const phrases = Array.isArray(data) && data.length > 1 && Array.isArray(data[1]) ? data[1] : [];
return phrases
.filter((phrase) => typeof phrase === 'string' && phrase.trim())
.slice(0, limit)
.map(function(p) { return { phrase: p }; });
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Check network connectivity and that duckduckgo.com is reachable (curl https://duckduckgo.com/ac/?q=test&type=list)
- Configure proxy environment variables (HTTPS_PROXY) if behind a firewall
- Retry — many failures are transient; add backoff
- Catch CommandExecutionError and surface a 'network unavailable' message to users
- Pin/fix TLS/DNS settings if the embedded message indicates a certificate or DNS problem
Example fix
// before
const s = await ddgSuggest({ keyword: 'cats' }); // throws on network error
// after
try {
const s = await ddgSuggest({ keyword: 'cats' });
} catch (err) {
if (err.message.includes('suggest request failed')) return []; // offline: no suggestions
throw err;
} Defensive patterns
Strategy: retry
Validate before calling
// probe connectivity first
const ok = await fetch('https://duckduckgo.com', { method: 'HEAD' }).then(r => r.ok).catch(() => false);
if (!ok) throw new Error('duckduckgo.com unreachable — check network/proxy'); Try / catch
try {
return await ddgSuggest({ keyword });
} catch (err) {
if (/suggest request failed/.test(err?.message ?? '')) {
await sleep(1000);
return ddgSuggest({ keyword }); // one retry for transient network issues
}
throw err;
} Prevention
- Configure HTTPS_PROXY in restricted environments
- Add exponential backoff around network calls
- Check DNS/VPN when running in CI or corporate networks
- Fail soft (return []) when suggestions are optional
When it happens
Trigger: fetch() rejects when calling the suggest endpoint: no internet, DNS resolution failure, connection refused/reset, TLS/certificate problems, or request timeout/abort.
Common situations: Running in an offline or air-gapped environment; corporate proxy/firewall blocking duckduckgo.com; DNS misconfiguration; IPv6 issues; transient network outage in CI.
Related errors
- coingecko categories request failed: ${err?.message ?? err}
- archive search request failed: ${error?.message || error}
- archive search returned malformed JSON: ${error?.message ||
- coingecko exchanges request failed: ${err?.message ?? err}
- coingecko global request failed: ${err?.message ?? err}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/2e3d8d4f680cb6e2.
Report an issue: GitHub.