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

chore: properly increase available ports #4666

Merged
merged 3 commits into from
Jun 7, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
# This improves Windows network performance, we need this since we open many ports in our tests
- name: Increase Windows port limit and reduce time wait delay
run: |
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters /v MaxUserPort /t REG_DWORD /d 32768 /f
netsh int ipv4 set dynamicport tcp start=1025 num=64511
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters /v TcpTimedWaitDelay /t REG_DWORD /d 30 /f
if: "${{ matrix.os == 'windows-latest' && !steps.release-check.outputs.IS_RELEASE }}"
- name: Git checkout
Expand Down
13 changes: 0 additions & 13 deletions npm-shrinkwrap.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@
"nock": "^13.2.4",
"p-timeout": "^4.0.0",
"rewiremock": "^3.14.3",
"seedrandom": "^3.0.5",
"serialize-javascript": "^6.0.0",
"sinon": "^13.0.0",
"sort-on": "^4.1.0",
Expand Down
21 changes: 3 additions & 18 deletions tests/integration/utils/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,11 @@ const execa = require('execa')
const getPort = require('get-port')
const omit = require('omit.js').default
const pTimeout = require('p-timeout')
const seedrandom = require('seedrandom')

const cliPath = require('./cli-path')
const { handleQuestions } = require('./handle-questions')
const { killProcess } = require('./process')

// each process gets a starting port based on the pid
const rng = seedrandom(`${process.pid}`)
const getRandomPortStart = function () {
const startPort = Math.floor(rng() * RANDOM_PORT_SHIFT) + RANDOM_PORT_SHIFT
return startPort
}

// To avoid collisions with frameworks ports
const RANDOM_PORT_SHIFT = 1e4
const FRAMEWORK_PORT_SHIFT = 1e3

let currentPort = getRandomPortStart()

const ENVS_TO_OMIT = ['LANG', 'LC_ALL']

const getExecaOptions = ({ cwd, env }) => ({
Expand All @@ -34,15 +20,14 @@ const getExecaOptions = ({ cwd, env }) => ({
})

const startServer = async ({ cwd, offline = true, env = {}, args = [], expectFailure = false, prompt }) => {
const tryPort = currentPort
currentPort += 1
const port = await getPort({ port: tryPort })
const port = await getPort()
const staticPort = await getPort()
const host = 'localhost'
const url = `http://${host}:${port}`
console.log(`Starting dev server on port: ${port} in directory ${path.basename(cwd)}`)
const ps = execa(
cliPath,
['dev', offline ? '--offline' : '', '-p', port, '--staticServerPort', port + FRAMEWORK_PORT_SHIFT, ...args],
['dev', offline ? '--offline' : '', '-p', port, '--staticServerPort', staticPort, ...args],
getExecaOptions({ cwd, env }),
)

Expand Down