(url: string, timeoutMs: number)
| 62 | }; |
| 63 | |
| 64 | async function probe(url: string, timeoutMs: number): Promise<{ reachable: boolean; latencyMs: number | null }> { |
| 65 | const start = Date.now(); |
| 66 | const ctrl = new AbortController(); |
| 67 | const t = setTimeout(() => ctrl.abort(), timeoutMs); |
| 68 | try { |
| 69 | const res = await proxyFetch(url, { method: 'GET', signal: ctrl.signal, redirect: 'follow' }); |
| 70 | clearTimeout(t); |
| 71 | // Any HTTP response (even 4xx) means the host is reachable; we only care that |
| 72 | // the TCP+TLS+routing path works, not the specific status. |
| 73 | return { reachable: res.status > 0, latencyMs: Date.now() - start }; |
| 74 | } catch { |
| 75 | clearTimeout(t); |
| 76 | return { reachable: false, latencyMs: null }; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | const Args = z.object({ |
| 81 | ecosystems: z.array(z.enum(['npm', 'pip', 'huggingface', 'github'])).optional() |
no test coverage detected