
















@@ -1040,6 +1040,23 @@ describe("buildGuardedModelFetch", () => {
10401040expect(response.headers.get("x-should-retry")).toBeNull();
10411041});
104210421043+it("bypasses unsafe retry-after-ms numeric headers", async () => {
1044+fetchWithSsrFGuardMock.mockResolvedValue({
1045+response: new Response(null, {
1046+status: 503,
1047+headers: { "retry-after-ms": "9007199254740993" },
1048+}),
1049+finalUrl: "https://api.openai.com/v1/responses",
1050+release: vi.fn(async () => undefined),
1051+});
1052+const response = await buildGuardedModelFetch(openaiModel)(
1053+"https://api.openai.com/v1/responses",
1054+{ method: "POST" },
1055+);
1056+1057+expect(response.headers.get("x-should-retry")).toBe("false");
1058+});
1059+10431060it("falls back to retry-after when retry-after-ms is blank", async () => {
10441061fetchWithSsrFGuardMock.mockResolvedValue({
10451062response: new Response(null, {
@@ -1193,6 +1210,24 @@ describe("buildGuardedModelFetch", () => {
11931210},
11941211);
119512121213+it("ignores unsafe OPENCLAW_SDK_RETRY_MAX_WAIT_SECONDS values", async () => {
1214+process.env.OPENCLAW_SDK_RETRY_MAX_WAIT_SECONDS = "9007199254740993";
1215+fetchWithSsrFGuardMock.mockResolvedValue({
1216+response: new Response(null, {
1217+status: 429,
1218+headers: { "retry-after": "30" },
1219+}),
1220+finalUrl: "https://api.anthropic.com/v1/messages",
1221+release: vi.fn(async () => undefined),
1222+});
1223+const response = await buildGuardedModelFetch(anthropicModel)(
1224+"https://api.anthropic.com/v1/messages",
1225+{ method: "POST" },
1226+);
1227+1228+expect(response.headers.get("x-should-retry")).toBeNull();
1229+});
1230+11961231it("injects x-should-retry:false for terminal 429 responses without retry-after", async () => {
11971232fetchWithSsrFGuardMock.mockResolvedValue({
11981233response: new Response("Sorry, you've exceeded your weekly rate limit.", {
@@ -1264,7 +1299,7 @@ describe("buildGuardedModelFetch", () => {
12641299expect(response.headers.get("x-should-retry")).toBeNull();
12651300});
126613011267-it.each(["soon", "1.5", "0x10"])(
1302+it.each(["soon", "1.5", "0x10", "9007199254740993"])(
12681303"treats malformed 429 retry-after values as terminal: %s",
12691304async (retryAfter) => {
12701305fetchWithSsrFGuardMock.mockResolvedValue({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。