Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(retry-markdown-links): cover timeout retries and renamed helper

Steven Enamakel799cde152865
diff --git a/scripts/__tests__/retry-markdown-links.test.mjs b/scripts/__tests__/retry-markdown-links.test.mjs
index 4135b362d6..c11947dc22 100644
--- a/scripts/__tests__/retry-markdown-links.test.mjs
+++ b/scripts/__tests__/retry-markdown-links.test.mjs
@@ -2,13 +2,14 @@ import assert from "node:assert/strict";
import test from "node:test";
import {
retryServiceUnavailable,
- serviceUnavailableUrls,
+ retryableFailureUrls,
} from "../ci/retry-markdown-links.mjs";
const unavailable =
"* [503] <https://example.test/docs#anchor> | Service Unavailable\n";
const internalError =
"* [500] <https://example.test/docs#anchor> | Internal Server Error\n";
+const timeout = "* [TIMEOUT] <https://example.test/docs#anchor> | Request timed out\n";
const missing = "* [404] <https://example.test/missing> | Not Found\n";
function checker(results) {
@@ -68,6 +69,27 @@ test("transient GitHub 500 responses are retried too", async () => {
]);
});
+test("transient request timeouts are retried", async () => {
+ const { calls, check } = checker([
+ { status: 2, report: timeout },
+ { status: 0, report: "" },
+ ]);
+ const waits = [];
+ assert.equal(
+ await retryServiceUnavailable({
+ initialReport: timeout,
+ check,
+ wait: async (ms) => waits.push(ms),
+ }),
+ 0,
+ );
+ assert.deepEqual(calls, [
+ ["https://example.test/docs#anchor"],
+ ["https://example.test/docs#anchor"],
+ ]);
+ assert.deepEqual(waits, [5000, 10000]);
+});
+
test("persistent 503 remains a failure after bounded retries", async () => {
const { calls, check } = checker(
Array.from({ length: 3 }, () => ({ status: 2, report: unavailable })),
@@ -117,7 +139,7 @@ test("a permanent error discovered on retry remains a failure", async () => {
});
test("retry inputs deduplicate repeated failures without dropping URL fragments", () => {
- assert.deepEqual(serviceUnavailableUrls(unavailable.repeat(3)), [
+ assert.deepEqual(retryableFailureUrls(unavailable.repeat(3)), [
"https://example.test/docs#anchor",
]);
});