From 744ef7068aea7ac93207552d291e4c363d4f0276 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 4 Mar 2022 19:19:06 +0100 Subject: [PATCH] fix: increase free port lookup range (#2010) Closes #2009 --- src/daemon/config.js | 12 ++++++------ test/e2e/launch.e2e.test.js | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/daemon/config.js b/src/daemon/config.js index f82ab0aed..0c109ce2c 100644 --- a/src/daemon/config.js +++ b/src/daemon/config.js @@ -175,6 +175,11 @@ async function checkIfAddrIsDaemon (addr) { }) } +const findFreePort = async (port) => { + port = Math.max(port, 1024) + return portfinder.getPortPromise({ port }) +} + async function checkPortsArray (ipfsd, addrs) { addrs = addrs.filter(Boolean) @@ -192,7 +197,7 @@ async function checkPortsArray (ipfsd, addrs) { continue } - const freePort = await portfinder.getPortPromise({ port: port, stopPort: port + 100 }) + const freePort = await findFreePort(port) if (port !== freePort) { const opt = showDialog({ @@ -239,11 +244,6 @@ async function checkPorts (ipfsd) { const apiPort = parseInt(configApiMa.nodeAddress().port, 10) const gatewayPort = parseInt(configGatewayMa.nodeAddress().port, 10) - const findFreePort = async (port) => { - port = Math.max(port, 1024) - return portfinder.getPortPromise({ port, stopPort: port + 100 }) - } - const freeGatewayPort = await findFreePort(gatewayPort) let freeApiPort = await findFreePort(apiPort) diff --git a/test/e2e/launch.e2e.test.js b/test/e2e/launch.e2e.test.js index c0fcf77db..cb845ddf1 100644 --- a/test/e2e/launch.e2e.test.js +++ b/test/e2e/launch.e2e.test.js @@ -7,8 +7,8 @@ const tmp = require('tmp') const { makeRepository } = require('./utils/ipfsd') const portfinder = require('portfinder') -async function getPort () { - return portfinder.getPortPromise() +async function getPort (port) { + return portfinder.getPortPromise({ port }) } if (process.env.CI === 'true') test.setTimeout(120000) // slow ci