MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / probe

Function probe

src/tools/network/network-optimize.ts:64–78  ·  view source on GitHub ↗
(url: string, timeoutMs: number)

Source from the content-addressed store, hash-verified

62};
63
64async 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
80const Args = z.object({
81 ecosystems: z.array(z.enum(['npm', 'pip', 'huggingface', 'github'])).optional()

Callers 1

executeMethod · 0.85

Calls 2

proxyFetchFunction · 0.85
abortMethod · 0.80

Tested by

no test coverage detected