GitShow/sindresorhus/get-port
sindresorhus

get-port

Get an available TCP port

by sindresorhus
Star on GitHubForknpm

JavaScript

929 stars65 forks21 contributorsQuiet · 5mo agoSince 2014v7.2.0MIT

Meet the team

See all 21 on GitHub →
sindresorhus
sindresorhus48 contributions
jonahsnider
jonahsnider2 contributions
nagen010
nagen0102 contributions
acostalima
acostalima1 contribution
arthurvr
arthurvr1 contribution
coreyfarrell
coreyfarrell1 contribution
sinterstice
sinterstice1 contribution
davidmarkclements
davidmarkclements1 contribution

Languages

View on GitHub →
JavaScript95.8%
TypeScript4.2%

Commit activity

Last 12 weeks · 0 commits

Full graph →

Community health

4 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template

Recent fixes

View closed PRs →
RobertCraigie
Custom cache timeoutClosedIssue

Currently the port cache timeout defaults to 15 seconds, but in my case I would like to use a higher timeout. Would be great if that could be configured.

RobertCraigie · 5mo ago
mikemykhaylov
Requested port is not assigned after 5.0.0 update, even though its availableClosedIssue

Hello, I have an issue. The code is: With version 4.2.0 the output is as expected With ^5.0.0, however, the second time I'm requesting the port, it comes out 1 more than before: Has anyone here encountered this issue or knows any way to solve it?

mikemykhaylov · 11mo ago
starrify
Race condition with user-specified port rangeClosedIssue

Summary It is assumed that there is a race condition relevant to this line: https://github.com/sindresorhus/get-port/blob/5c3cfe828bac345fb30b13211164708d97cb033a/index.js#L134 when the user sends a preferred port range (via the param). Analysis 1. Assuming that the user has previously called and acquired some available ports within the range. 2. Assuming that the loop at this line would iterate over the already-assigned ports. 3. Notice that at this line comes before the check, it would indeed proceed to the point where it attempts to bind to that port. 4. Assuming that the user then attempts to bind to the port, which is in use by . Therefore the race condition would be triggered. A PoC Sample code: Sample invocation (as of v7.1.0): Proposed fix ~Just to check against the assignment records () before attempting to bind to a non-zero port.~ Edit:** Hmm sorry that might not look that straightforward as there seem to be other possible causes of race conditions as well.

starrify · 11mo ago
Structured data for AI agents

Repository: sindresorhus/get-port. Description: Get an available TCP port Stars: 929, Forks: 65. Primary language: JavaScript. Languages: JavaScript (95.8%), TypeScript (4.2%). License: MIT. Latest release: v7.2.0 (5mo ago). Open PRs: 0, open issues: 1. Last activity: 5mo ago. Community health: 85%. Top contributors: sindresorhus, jonahsnider, nagen010, acostalima, arthurvr, coreyfarrell, sinterstice, davidmarkclements, BendingBender, mastrzyz and others.

·@ofershap

Replace github.com with gitshow.dev