How to use the tcp-port-used.waitUntilUsed function in tcp-port-used

To help you get started, we’ve selected a few tcp-port-used examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla-b2g / fxos-device-service / test / setup.js View on Github external
suiteSetup(async function() {
  chai.should();

  service.start({
    port: 3000,
    // Make sure that our fake adb gets used instead of the real thing.
    adbPath: path.resolve(__dirname, './adb')
  });

  await tcpPortUsed.waitUntilUsed(3000);
});
github ovh / manager / scripts / webpack-cypress.js View on Github external
fp(3000, (err, port) => {
  const webpackApp = execa('yarn', ['start:dev', '--port', port]);
  webpackApp.stdout.pipe(process.stdout);

  tcpPortUsed.waitUntilUsed(port, 500, 1000 * 60 * 5)
    .then(() => {
      const cypressShell = execa('cypress', ['run', '--config', `baseUrl=http://localhost:${port}`]);
      cypressShell.stdout.pipe(process.stdout);
      return cypressShell;
    })
    .then(() => kill(port))
    .then(() => process.exit(0))
    .catch((err) => { console.error(err); process.exit(1); }); // eslint-disable-line no-shadow
});
github Financial-Times / x-dash / athloi.js View on Github external
run(options) {
			const openUrl = openUrls[options.open];
			const port = parseInt(url.parse(openUrl).port, 10);

			if(port) {
				// wait for whatever (storybook/gatsby) to be listening on the port
				// try every 500ms and give up after 30s
				tcpPortUsed.waitUntilUsed(port, 500, 30000)
					.then(() => open(openUrl))
					.catch(e => console.error(e.stack));
			}

			return tasks.start.run(options);
		},
	}),
github aws / aws-toolkit-vscode / src / shared / codelens / localLambdaRunner.ts View on Github external
export async function waitForDebugPort(
    debugPort: number,
    timeoutDuration: number,
    channelLogger: ChannelLogger
): Promise {
    try {
        // this function always attempts once no matter the timeoutDuration
        await tcpPortUsed.waitUntilUsed(debugPort, SAM_LOCAL_PORT_CHECK_RETRY_INTERVAL_MILLIS, timeoutDuration)
    } catch (err) {
        getLogger().warn(`Timed out after ${timeoutDuration} ms waiting for port ${debugPort} to open`, err as Error)

        channelLogger.warn(
            'AWS.samcli.local.invoke.port.not.open',
            // tslint:disable-next-line:max-line-length
            "The debug port doesn't appear to be open. The debugger might not succeed when attaching to your SAM Application."
        )
    }
}
github lambdabaa / dav / test / integration / server / bootstrap.js View on Github external
'127.0.0.1:8888',
    'calendarserver.php'
  ], {
    cwd: __dirname + '/SabreDAV'
  });

  server.stdout.on('data', function(chunk) {
    debug(chunk.toString());
  });

  server.stderr.on('data', function(chunk) {
    debug(chunk.toString());
  });

  debug('Wait for dav server to start.');
  return tcpPortUsed.waitUntilUsed(8888, 100, 20000);
});
github giggio / node-chromedriver / lib / chromedriver.js View on Github external
if (!fs.existsSync(command)) {
    console.log('Could not find chromedriver in default path: ', command);
    console.log('Falling back to use global chromedriver bin');
    command = process.platform === 'win32' ? 'chromedriver.exe' : 'chromedriver';
  }
  const cp = require('child_process').spawn(command, args);
  cp.stdout.pipe(process.stdout);
  cp.stderr.pipe(process.stderr);
  exports.defaultInstance = cp;
  if (!returnPromise) {
    return cp;
  }
  const port = getPortFromArgs(args);
  const pollInterval = 100;
  const timeout = 10000;
  return tcpPortUsed.waitUntilUsed(port, pollInterval, timeout)
    .then(function () {
      return cp;
    });
};
exports.stop = function () {
github zordius / fluxex / extra / gulpfile.js View on Github external
proxy: 'http://localhost:' + configs.port,
                    files: [configs.static_dir + 'css/*.css'],
                    port: configs.BSport,
                    online: false,
                    open: false,
                    snippetOptions: {
                        rule: {
                            match: /<\/html>$/,
                            fn: function (s, m) {
                                return m + s;
                            }
                        }
                    }
                });

                TPU.waitUntilUsed(configs.port, 200, 30000).then(function () {
                    serverStarted = true;
                    browserSync.reload();
                });
            }
        });
});
github DonJayamanne / vscodeJupyter / src / jupyterServices / notebook / factory.ts View on Github external
.then(nextAvailablePort => {
                url = `${protocol}://${ip}:${nextAvailablePort}`;
                return tcpPortUsed.waitUntilUsed(nextAvailablePort, retryIntervalMs, timeoutMs);
            })
            .then(() => {

tcp-port-used

A simple Node.js module to check if a TCP port is already bound.

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis