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

Function freePort

e2e/desktop-packaged/supervised-attach.test.ts:184–192  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

182}
183
184const freePort = (): Promise<number> =>
185 new Promise((resolve, reject) => {
186 const srv = net.createServer();
187 srv.on("error", reject);
188 srv.listen(0, "127.0.0.1", () => {
189 const port = (srv.address() as net.AddressInfo).port;
190 srv.close(() => resolve(port));
191 });
192 });
193
194interface Manifest {
195 readonly kind: string;

Callers 1

runFunction · 0.70

Calls 4

listenMethod · 0.80
addressMethod · 0.80
closeMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected