getPort ignores HOST, so a port in use on another interface forces a random PORT
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- node.js, typescript
- Lĩnh vực
- tooling
Hướng nghiên cứu
Bắt đầu từ điểm vào getPort() được dev server và node ace test sử dụng, theo dõi cả nhánh process.env.PORT lẫn nhánh được suy ra từ .env. Tái hiện với HOST và PORT trên các giao diện loopback riêng biệt, sau đó xác minh rằng cổng được cấu hình vẫn được giữ lại khi còn trống trên host đó và các bài kiểm thử assembler liên quan đều đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 40
- Fork
- 24
- Merge trung bình
- 10 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của adonisjs/assembler
-
Ctrl+C does not stop the dev server: raw mode suppresses SIGINT and close() never exits the processĐang mởStatus: Awaiting More Information
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
-
Support of typescript 7Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
-
OpenAPI schema generationCó thể làm lại được @thetutlage đã nhận 92 ngày trước và không có pull request nào đang mở. Đang mở
Tất cả issue của adonisjs/assembler
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
umbraco/Umbraco-CMS-MCP-Dev#512 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
wimpysworld/sidra#290 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
defuFn invokes function values for inherited default propertiesCó thể đã có người làm @xiehuanyi đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
feature request good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
TabularisDB/tabularis#853 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 85/100
capricorn86/happy-dom#2474 ·
Maintainer thường phản hồi trong vòng 2 ngày