mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 13:07:39 +00:00
fix(agents): trigger model failover on connection-refused and network-unreachable errors
Previously, only ETIMEDOUT / ESOCKETTIMEDOUT / ECONNRESET / ECONNABORTED were recognised as failover-worthy network errors. Connection-level failures such as ECONNREFUSED (server down), ENETUNREACH / EHOSTUNREACH (network disconnected), ENETRESET, and EAI_AGAIN (DNS failure) were treated as unknown errors and did not advance the fallback chain. This is particularly impactful when a local fallback model (e.g. Ollama) is configured: if the remote provider is unreachable due to a network outage, the gateway should fall back to the local model instead of returning an error to the user. Add the missing error codes to resolveFailoverReasonFromError() and corresponding e2e tests. Closes #18868
This commit is contained in:
@@ -183,7 +183,19 @@ export function resolveFailoverReasonFromError(err: unknown): FailoverReason | n
|
||||
}
|
||||
|
||||
const code = (getErrorCode(err) ?? "").toUpperCase();
|
||||
if (["ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNRESET", "ECONNABORTED"].includes(code)) {
|
||||
if (
|
||||
[
|
||||
"ETIMEDOUT",
|
||||
"ESOCKETTIMEDOUT",
|
||||
"ECONNRESET",
|
||||
"ECONNABORTED",
|
||||
"ECONNREFUSED",
|
||||
"ENETUNREACH",
|
||||
"EHOSTUNREACH",
|
||||
"ENETRESET",
|
||||
"EAI_AGAIN",
|
||||
].includes(code)
|
||||
) {
|
||||
return "timeout";
|
||||
}
|
||||
if (isTimeoutError(err)) {
|
||||
|
||||
Reference in New Issue
Block a user