Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use portfinder instead of get-port #1410

Merged
merged 1 commit into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"electron-updater": "^4.2.5",
"fix-path": "^3.0.0",
"fs-extra": "^9.0.0",
"get-port": "^5.1.1",
"go-ipfs-dep": "0.4.23",
"i18next": "^19.4.2",
"i18next-electron-language-detector": "0.0.10",
Expand All @@ -90,6 +89,7 @@
"is-ipfs": "^1.0.0",
"multiaddr": "^7.4.3",
"multiaddr-to-uri": "^5.1.0",
"portfinder": "^1.0.25",
"recursive-readdir": "^2.2.2",
"stream-to-pull-stream": "^1.7.3",
"sudo-prompt": "^9.1.1",
Expand Down
8 changes: 4 additions & 4 deletions src/daemon/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { join } = require('path')
const fs = require('fs-extra')
const multiaddr = require('multiaddr')
const http = require('http')
const getPort = require('get-port')
const portfinder = require('portfinder')
const { shell } = require('electron')
const i18n = require('i18next')
const { showDialog } = require('../dialogs')
Expand Down Expand Up @@ -137,7 +137,7 @@ async function checkPortsArray (ipfsd, addrs) {
continue
}

const freePort = await getPort({ port: getPort.makeRange(port, port + 100) })
const freePort = await portfinder.getPortPromise({ port: port, stopPort: port + 100 })

if (port !== freePort) {
const opt = showDialog({
Expand Down Expand Up @@ -184,8 +184,8 @@ async function checkPorts (ipfsd) {
const apiPort = parseInt(configApiMa.nodeAddress().port, 10)
const gatewayPort = parseInt(configGatewayMa.nodeAddress().port, 10)

const freeGatewayPort = await getPort({ port: getPort.makeRange(gatewayPort, gatewayPort + 100) })
const freeApiPort = await getPort({ port: getPort.makeRange(apiPort, apiPort + 100) })
const freeGatewayPort = await portfinder.getPortPromise({ port: gatewayPort, stopPort: gatewayPort + 100 })
const freeApiPort = await portfinder.getPortPromise({ port: apiPort, stopPort: apiPort + 100 })

const busyApiPort = apiPort !== freeApiPort
const busyGatewayPort = gatewayPort !== freeGatewayPort
Expand Down
6 changes: 5 additions & 1 deletion test/e2e/launch.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const delay = require('delay')
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const { makeRepository } = require('./utils/ipfsd')
const getPort = require('get-port')
const portfinder = require('portfinder')

const expect = chai.expect
chai.use(dirtyChai)
Expand All @@ -23,6 +23,10 @@ function createTmpDir () {
return tmp.dirSync({ unsafeCleanup: true }).name
}

async function getPort () {
return portfinder.getPortPromise()
}

const timeout = process.env.CI ? 180000 : 60000

describe('Application launch', function () {
Expand Down