mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 18:08:27 +00:00
(fix): handle Cloudflare 521 and transient 5xx errors gracefully (#13500)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: a8347e95c5
Co-authored-by: rodrigouroz <384037+rodrigouroz@users.noreply.github.com>
Co-authored-by: Takhoffman <781889+Takhoffman@users.noreply.github.com>
Reviewed-by: @Takhoffman
This commit is contained in:
18
src/agents/pi-embedded-helpers.istransienthttperror.test.ts
Normal file
18
src/agents/pi-embedded-helpers.istransienthttperror.test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isTransientHttpError } from "./pi-embedded-helpers.js";
|
||||
|
||||
describe("isTransientHttpError", () => {
|
||||
it("returns true for retryable 5xx status codes", () => {
|
||||
expect(isTransientHttpError("500 Internal Server Error")).toBe(true);
|
||||
expect(isTransientHttpError("502 Bad Gateway")).toBe(true);
|
||||
expect(isTransientHttpError("503 Service Unavailable")).toBe(true);
|
||||
expect(isTransientHttpError("521 <!DOCTYPE html><html></html>")).toBe(true);
|
||||
expect(isTransientHttpError("529 Overloaded")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false for non-retryable or non-http text", () => {
|
||||
expect(isTransientHttpError("504 Gateway Timeout")).toBe(false);
|
||||
expect(isTransientHttpError("429 Too Many Requests")).toBe(false);
|
||||
expect(isTransientHttpError("network timeout")).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user