getPort ignores HOST, so a port in use on another interface forces a random PORT
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
- Ambito
- tooling
Direzione di ricerca
Inizia dal punto di ingresso getPort() utilizzato dal server di sviluppo e da node ace test, tracciando sia il ramo process.env.PORT sia quello derivato da .env. Riproduci il problema con HOST e PORT su interfacce loopback separate, quindi verifica che la porta configurata venga mantenuta quando è libera su quell’host e che i test assembler pertinenti passino.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Alias a second loopback address (macOS:
sudo ifconfig lo0 alias 127.1.1.63). - Occupy the port there:
node -e "require('net').createServer().listen(3333, '127.1.1.63')" - In an Adonis app:
HOST=127.0.0.1 PORT=3333 NODE_DEBUG=adonisjs:core node ace test functional - The debug line shows
listening to utils http server, host :127.0.0.1, port: <random>, although127.0.0.1:3333is 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.
- Lingua principale
- TypeScript
- Stelle
- 40
- Fork
- 24
- Merge medio
- 10g 22h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di adonisjs/assembler
-
Ctrl+C does not stop the dev server: raw mode suppresses SIGINT and close() never exits the processApertaStatus: Awaiting More Information
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
-
Support of typescript 7Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
-
OpenAPI schema generationForse di nuovo libera @thetutlage l’ha presa 94 giorni fa e non c’è nessuna pull request aperta. Aperta
Tutte le issue di adonisjs/assembler
Issue simili
-
[bug] diagnostics.dumpBody:Buffer 形态请求(透传 lane)跳过 dumps/ 落盘,仅留 raw/-unknown-Forse già presa @ranxianglei l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ranxianglei/billion-context#2421 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
pending triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
nuxt/test-utils#1842 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
MoonshotAI/kimi-code#4146 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
farbenmeer/tapi#531 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno