MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / fetchStatus

Function fetchStatus

scripts/check-owned-links.js:48–73  ·  view source on GitHub ↗
(url, method, retries = 3)

Source from the content-addressed store, hash-verified

46}
47
48async function fetchStatus(url, method, retries = 3) {
49 for (let attempt = 0; attempt <= retries; attempt++) {
50 try {
51 const response = await fetch(url, {
52 method,
53 redirect: 'follow',
54 headers: {
55 'User-Agent': 'adcp-owned-link-check/1.0',
56 },
57 signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
58 });
59 if (response.status >= 500 && attempt < retries) {
60 await new Promise((r) => setTimeout(r, 2000 * (attempt + 1)));
61 continue;
62 }
63 return response.status;
64 } catch (err) {
65 if (attempt < retries) {
66 await new Promise((r) => setTimeout(r, 2000 * (attempt + 1)));
67 continue;
68 }
69 throw err;
70 }
71 }
72 throw new Error(`fetchStatus exhausted retries without returning for ${url}`);
73}
74
75// 405 means the endpoint exists but rejects this HTTP method (e.g. MCP
76// Streamable-HTTP endpoints reject GET). Treat as reachable.

Callers 1

checkUrlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected