MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / bindProbe

Function bindProbe

e2e/src/ports.ts:111–122  ·  view source on GitHub ↗
(port: number)

Source from the content-addressed store, hash-verified

109// microseconds (close, then boot). Services bind 127.0.0.1 or dual-stack `::`,
110// both of which succeed once the probes are released.
111const bindProbe = async (port: number): Promise<ReadonlyArray<Server> | undefined> => {
112 const loopbacks = await Promise.all(["127.0.0.1", "::1"].map((host) => isListening(port, host)));
113 if (loopbacks.some(Boolean)) return undefined;
114 const v4 = await listenOn({ port, host: "0.0.0.0" });
115 if (!v4) return undefined;
116 const v6 = await listenOn({ port, host: "::", ipv6Only: true });
117 if (!v6) {
118 await closeServer(v4);
119 return undefined;
120 }
121 return [v4, v6];
122};
123
124export interface PortClaim {
125 readonly envVar: string;

Callers 1

claimPortsFunction · 0.85

Calls 3

isListeningFunction · 0.85
listenOnFunction · 0.85
closeServerFunction · 0.70

Tested by

no test coverage detected