jackwener/OpenCLI · error · CommandExecutionError
weread-official ${apiName} request failed
Error message
weread-official ${apiName} request failed What it means
Generic fetch failure inside callGateway. TimeoutError handles aborts; any other thrown error (network reset, invalid URL, socket hangup) becomes CommandExecutionError with the original error message as detail.
Source
Thrown at clis/weread-official/utils.js:98
let response;
try {
response = await fetch(WEREAD_GATEWAY_URL, {
method: 'POST',
headers: {
Authorization: `Bearer ${key}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
signal: controller.signal,
});
}
catch (error) {
if (error?.name === 'AbortError') {
throw new TimeoutError(`weread-official ${apiName}`, Math.round(timeoutMs / 1000));
}
const detail = error instanceof Error ? error.message : String(error);
throw new CommandExecutionError(`weread-official ${apiName} request failed`, detail);
}
finally {
clearTimeout(timer);
}
if (!response.ok) {
throw new CommandExecutionError(
`weread-official ${apiName} HTTP ${response.status}`,
'Check WeRead gateway availability and that WEREAD_API_KEY is still valid.',
);
}
let payload;
try {
payload = await response.json();
}
catch (error) {
const detail = error instanceof Error ? error.message : String(error);View on GitHub (pinned to 49907e53dc)
Solutions
- Read error.detail for the underlying message (e.g. getaddrinfo ENOTFOUND).
- Fix DNS/proxy/connectivity indicated by the detail message.
- Verify the gateway base URL/domain configuration.
- Retry with backoff for transient socket errors.
Defensive patterns
Strategy: try-catch
Validate before calling
new URL(gatewayUrl); // throws early if the base URL is malformed
Type guard
const isFetchError = (e) => e instanceof CommandExecutionError && /request failed/.test(e.message);
Try / catch
try {
return await callGateway(apiName, params);
} catch (e) {
if (e instanceof CommandExecutionError && e.detail) {
console.error(`weread-official ${apiName}: underlying cause: ${e.detail}`);
}
throw e;
} Prevention
- Log error.detail — it carries the original fetch message
- Verify gateway base URL configuration
- Handle transient network errors with bounded retries
- Avoid calling the gateway from flaky connections without backoff
When it happens
Trigger: Connection reset mid-request, malformed request URL, DNS resolution failure, or fetch throwing synchronously — anything that is not an AbortError in the catch block.
Common situations: VPN dropping mid-call; gateway closing keep-alive connections; Node fetch failing on an unreachable host; mistyped gateway base URL in configuration.
Related errors
- Failed to fetch Chess.com callback ${url}: ${error?.message
- ${label} request failed: ${err?.message ?? err}. Check that
- ${label} request failed: ${err?.message ?? err}
- mdn search request failed: ${err?.message ?? err}
- network error fetching signed URL: ${e.message}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f8e6b214fc8e233f.
Report an issue: GitHub.