mirror of https://github.com/openclaw/openclaw.git
fix: move cause-chain traversal before timeout heuristic (review feedback)
This commit is contained in:
parent
dac220bd88
commit
c1c74f9952
|
|
@ -238,10 +238,9 @@ export function resolveFailoverReasonFromError(err: unknown): FailoverReason | n
|
|||
) {
|
||||
return "timeout";
|
||||
}
|
||||
if (isTimeoutError(err)) {
|
||||
return "timeout";
|
||||
}
|
||||
// Walk into error cause chain (e.g. AbortError wrapping a rate-limit cause)
|
||||
// Walk into error cause chain *before* timeout heuristics so that a specific
|
||||
// cause (e.g. RESOURCE_EXHAUSTED wrapped in AbortError) overrides a parent
|
||||
// message-based "timeout" guess from isTimeoutError.
|
||||
const cause = getErrorCause(err);
|
||||
if (cause && cause !== err) {
|
||||
const causeReason = resolveFailoverReasonFromError(cause);
|
||||
|
|
@ -249,6 +248,9 @@ export function resolveFailoverReasonFromError(err: unknown): FailoverReason | n
|
|||
return causeReason;
|
||||
}
|
||||
}
|
||||
if (isTimeoutError(err)) {
|
||||
return "timeout";
|
||||
}
|
||||
if (!message) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -394,6 +394,15 @@ describe("runWithModelFallback – probe logic", () => {
|
|||
|
||||
// All three candidates must be attempted — the abort must not short-circuit
|
||||
expect(run).toHaveBeenCalledTimes(3);
|
||||
|
||||
// Verify the primary error is classified as rate_limit, not timeout — the
|
||||
// cause chain (RESOURCE_EXHAUSTED) must override the parent AbortError message.
|
||||
try {
|
||||
await runWithModelFallback({ cfg, provider: "google", model: "gemini-3-flash-preview", run });
|
||||
} catch (err) {
|
||||
expect(String(err)).toContain("(rate_limit)");
|
||||
expect(String(err)).not.toMatch(/gemini.*\(timeout\)/);
|
||||
}
|
||||
expect(run).toHaveBeenNthCalledWith(1, "google", "gemini-3-flash-preview", {
|
||||
allowTransientCooldownProbe: true,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue