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

Function fetchWithTimeout

server/src/services/brand-logo-service.ts:59–67  ·  view source on GitHub ↗
(method: 'HEAD' | 'GET')

Source from the content-addressed store, hash-verified

57 const FETCH_TIMEOUT_MS = 5000;
58
59 async function fetchWithTimeout(method: 'HEAD' | 'GET'): Promise<Response> {
60 const controller = new AbortController();
61 const timer = setTimeout(() => controller.abort(new Error('Logo URL check timed out')), FETCH_TIMEOUT_MS);
62 try {
63 return await safeFetch(rawUrl, { method, maxRedirects: 3, signal: controller.signal });
64 } finally {
65 clearTimeout(timer);
66 }
67 }
68
69 // Cancel response bodies we never read so a malicious slow-body server
70 // can't tie up a connection for the full timeout window.

Callers 1

checkLogoUrlIsImageFunction · 0.85

Calls 1

safeFetchFunction · 0.85

Tested by

no test coverage detected