MCPcopy Index your code
hub / github.com/BlockRunAI/ClawRouter / checkExistingProxy

Function checkExistingProxy

src/proxy.ts:636–663  ·  view source on GitHub ↗

* Check if a proxy is already running on the given port. * Returns the wallet address if running, undefined otherwise.

(
  port: number,
)

Source from the content-addressed store, hash-verified

634 * Returns the wallet address if running, undefined otherwise.
635 */
636async function checkExistingProxy(
637 port: number,
638): Promise<{ wallet: string; paymentChain?: string } | undefined> {
639 const controller = new AbortController();
640 const timeoutId = setTimeout(() => controller.abort(), HEALTH_CHECK_TIMEOUT_MS);
641
642 try {
643 const response = await fetch(`http://127.0.0.1:${port}/health`, {
644 signal: controller.signal,
645 });
646 clearTimeout(timeoutId);
647
648 if (response.ok) {
649 const data = (await response.json()) as {
650 status?: string;
651 wallet?: string;
652 paymentChain?: string;
653 };
654 if (data.status === "ok" && data.wallet) {
655 return { wallet: data.wallet, paymentChain: data.paymentChain };
656 }
657 }
658 return undefined;
659 } catch {
660 clearTimeout(timeoutId);
661 return undefined;
662 }
663}
664
665/**
666 * Error patterns that indicate a provider-side issue (not user's fault).

Callers 2

startProxyFunction · 0.85
onErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected