MCPcopy Create free account
hub / github.com/anus-dev/ANUS / waitForPort

Function waitForPort

scripts/telemetry_utils.js:141–161  ·  view source on GitHub ↗
(port, timeout = 10000)

Source from the content-addressed store, hash-verified

139}
140
141export function waitForPort(port, timeout = 10000) {
142 return new Promise((resolve, reject) => {
143 const startTime = Date.now();
144 const tryConnect = () => {
145 const socket = new net.Socket();
146 socket.once('connect', () => {
147 socket.end();
148 resolve();
149 });
150 socket.once('error', (_) => {
151 if (Date.now() - startTime > timeout) {
152 reject(new Error(`Timeout waiting for port ${port} to open.`));
153 } else {
154 setTimeout(tryConnect, 500);
155 }
156 });
157 socket.connect(port, 'localhost');
158 };
159 tryConnect();
160 });
161}
162
163export async function ensureBinary(
164 executableName,

Callers 2

mainFunction · 0.90
mainFunction · 0.90

Calls 1

tryConnectFunction · 0.85

Tested by

no test coverage detected