Code Monkey home page Code Monkey logo

get-port-please's People

Contributors

antfu avatar atinux avatar danielroe avatar eddie344 avatar farnabaz avatar filiphazardous avatar mrazauskas avatar pi0 avatar renovate[bot] avatar seanghay avatar vvagaytsev avatar yuler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

get-port-please's Issues

Timeout waiting for port

Environment

get-port-please v3.0.1
Node.js v16.20.0

Reproduction

https://stackblitz.com/edit/stackblitz-starters-vdm76f?description=Starter%20project%20for%20Node.js,%20a%20JavaScript%20runtime%20built%20on%20Chrome%27s%20V8%20JavaScript%20engine&file=index.mjs,package-lock.json&title=node.new%20Starter

Describe the bug

I get

Error: Timeout waiting for port 59728 after 4 retries with 500ms interval.
    at async ESMLoader.import (https://stackblitzstartersvdm76f-xrf4.w-credentialless.staticblitz.com/blitz.33975f1d.js:213:4862)
    at async i.loadESM (https://stackblitzstartersvdm76f-xrf4.w-credentialless.staticblitz.com/blitz.33975f1d.js:60:915)
    at async handleMainPromise (https://stackblitzstartersvdm76f-xrf4.w-credentialless.staticblitz.com/blitz.33975f1d.js:168:264)

when running await waitForPort().
It happens on StackBlitz and MacOS 13.5 (Node 16.20.0, 18.16.1 when running Nitro tests).

Additional context

No response

Logs

No response

Auto host fallback

Context: nuxt/nuxt#20019

When get-port-please is unable to obtain a port, the issue is usually because of a wrong hostname option. In order to improve DX, we shall implement a fallback strategy to try with localhost > 127.0.0.1 and "" (only if explicit public option is provided to avoid unwanted exposure)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update devdependency @types/node to ^20.11.27

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-node v4
  • codecov/codecov-action v3
npm
package.json
  • @types/node ^20.11.25
  • @vitest/coverage-v8 ^1.3.1
  • changelogen ^0.5.5
  • eslint ^8.57.0
  • eslint-config-unjs ^0.2.1
  • jiti ^1.21.0
  • prettier ^3.2.5
  • typescript ^5.4.2
  • unbuild ^2.0.0
  • vitest ^1.3.1
  • pnpm 8.15.4

  • Check this box to trigger a request for Renovate to run again on this repository

options.port default to 3000, even in the presence of options.ports

Environment

Node v18 (but I think it is universal)

Reproduction

The following repo gets the port 3000 unexpectedly: https://github.com/nuxt-modules/storybook/blob/main/src/storybook.ts (see line 11)

Here is the shortest snippet that reproduces the bug:

import { getPort } from 'get-port-please';
const port = getPort({ ports: [6006, 6007, 6008] });
if (port === 3000) {
  console.log('Port is unexpectedly returned as 3000');
}

Describe the bug

In the file get-ports.ts (https://github.com/unjs/get-port-please/blob/main/src/get-port.ts) on line 29 - the port option defaults to 3000 (unless otherwise defined in _userOptions). On line 53 in the same file, the same value is assigned a higher priority than the actually provided option ports. This makes the ports and portRange options hard to use.

If this behavior is intentional, it would be convenient if it was documented.

A suggested fix would be to add the default port to the end of portToCheck and unshift _userOptions.port to the front of the same array if it is provided.

Additional context

No response

Logs

This is a log generated by me putting `console.log` messages, outputting `_userOptions`, `options` and `availablePort` in the `index.mjs` file in `node_modules`. (feserver_1 being my docker container)

feserver_1  | _userOptions
feserver_1  |  {
feserver_1  |   "ports": [
feserver_1  |           443,
feserver_1  |           6007,
feserver_1  |           6008,
feserver_1  |           6009,
feserver_1  |           6010
feserver_1  |   ],
feserver_1  |   "verbose": true
feserver_1  | }
feserver_1  | options
feserver_1  |  {
feserver_1  |   "name": "default",
feserver_1  |   "random": false,
feserver_1  |   "ports": [
feserver_1  |           443,
feserver_1  |           6007,
feserver_1  |           6008,
feserver_1  |           6009,
feserver_1  |           6010
feserver_1  |   ],
feserver_1  |   "portRange": [],
feserver_1  |   "alternativePortRange": [
feserver_1  |           3000,
feserver_1  |           3100
feserver_1  |   ],
feserver_1  |   "verbose": true,
feserver_1  |   "port": 3000
feserver_1  | }
feserver_1  | availablePort:  3000

Package uses `process.env.PORT` all the time and ignores `port` option

Environment

.

Reproduction

.

Describe the bug

As the doc says, the package should use process.env.PORT as default value.

port
First port to check. Default is process.env.PORT || 3000

But as you can see here, it always uses environment variable if it is present.

port: Number.parseInt(process.env.PORT || "") || config.port || 3000

It is important to prioritize option over environment variable to make sure that we can use this package to get different ports if it's required.

originally reported in nuxt/content#1781

Additional context

No response

Logs

No response

doesn't detect collisions on macos

when I have a server running on port 3000 and call getPort(3000) it returns 3000 rather than detecting a port collision

it defaults to these server options:

console.log(server.address())
// { address: '::', family: 'IPv6', port: 3000 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.