(method: 'HEAD' | 'GET')
| 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. |
no test coverage detected