Skip to content

Commit

Permalink
fix: increase free port lookup range (#2010)
Browse files Browse the repository at this point in the history
Closes #2009
  • Loading branch information
lidel authored Mar 4, 2022
1 parent 1080448 commit 744ef70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/daemon/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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({
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/launch.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 744ef70

Please sign in to comment.