MCPcopy Index your code
hub / github.com/nodejs/node / waitForPort

Function waitForPort

test/sequential/test-tls-psk-client.js:61–74  ·  view source on GitHub ↗
(port, cb)

Source from the content-addressed store, hash-verified

59const timeout = setTimeout(() => cleanUp('Timed out'), 5000);
60
61function waitForPort(port, cb) {
62 const socket = net.connect(common.PORT, () => {
63 socket.on('data', () => {});
64 socket.end();
65 socket.on('end', cb);
66 });
67 socket.on('error', (e) => {
68 if (e.code === 'ENOENT' || e.code === 'ECONNREFUSED') {
69 setTimeout(() => waitForPort(port, cb), 1000);
70 } else {
71 cb(e);
72 }
73 });
74}
75
76waitForPort(common.PORT, common.mustCall((err) => {
77 if (err) {

Callers 1

Calls 5

cbFunction · 0.70
connectMethod · 0.65
setTimeoutFunction · 0.50
onMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…