Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

getPort ignores HOST, so a port in use on another interface forces a random PORT

Abierto Apto para principiantes
#115 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
75/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
node.js, typescript
Área
tooling

Línea de trabajo

Comienza en el punto de entrada getPort() utilizado por el servidor de desarrollo y node ace test, siguiendo tanto la rama de process.env.PORT como la derivada de .env. Reprodúcelo con HOST y PORT en interfaces de loopback separadas y verifica después que el puerto configurado se conserva cuando está libre en ese host y que las pruebas relevantes de assembler pasan.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Package: @adonisjs/assembler (seen on 7.8.2, still present in 8.5.2) with get-port 7.1.0

What happens

getPort() (used by the dev server and node ace test) calls:

getRandomPort({ port: Number(process.env.PORT) })   // no host

Without a host, get-port treats the port as taken if it is in use on undefined, 0.0.0.0 or any local interface address. So if port 3333 is bound on 127.1.1.63, node ace test configured with HOST=127.1.1.62 PORT=3333 is handed a random free PORT, even though 127.1.1.62:3333 is free.

The app then listens on 127.1.1.62:<random>. Anything that derives its URL from the configured port — typically a BASE_URL for supertest/@japa/api-client in functional tests — points at 127.1.1.62:3333 and every request fails with ECONNREFUSED.

Reproduce
  1. Alias a second loopback address (macOS: sudo ifconfig lo0 alias 127.1.1.63).
  2. Occupy the port there: node -e "require('net').createServer().listen(3333, '127.1.1.63')"
  3. In an Adonis app: HOST=127.0.0.1 PORT=3333 NODE_DEBUG=adonisjs:core node ace test functional
  4. The debug line shows listening to utils http server, host :127.0.0.1, port: <random>, although 127.0.0.1:3333 is free.
Why it matters

Running several checkouts' test suites side by side on one machine — each on its own loopback IP and the same port — is a natural way to parallelise. The run that starts last loses the race and fails every HTTP test, and nothing in the output says why.

Suggested fix

Pass the configured host through, so availability is checked where the server will actually bind:

getRandomPort({ port: Number(process.env.PORT), host: process.env.HOST })

(and the same for the .env-derived branch). When HOST is unset, behaviour stays as today.

Lenguaje dominante
TypeScript
Estrellas
40
Forks
24
Merge medio
10 d 22 h
PR fusionados (30 d)
4

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de adonisjs/assembler

Todos los issues de adonisjs/assembler

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.