From 03470f6091a1d8796f863b795d80e5f82ca9b194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caleb=20=E3=83=84=20Everett?= Date: Thu, 27 Jun 2019 19:17:03 -0700 Subject: [PATCH] test: bind to free port Bind to port 0 instead of 3000 Test does not require a well known port so it doesn't need port 3000 or common.PORT. Tests were failing on my CI box because port 3000 was already taken. --- test/async-hooks/test-httparser-reuse.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/async-hooks/test-httparser-reuse.js b/test/async-hooks/test-httparser-reuse.js index 06441562e05aa8..13d1d0168be615 100644 --- a/test/async-hooks/test-httparser-reuse.js +++ b/test/async-hooks/test-httparser-reuse.js @@ -47,13 +47,12 @@ const server = http.createServer((req, res) => { res.end(); }); -const PORT = 3000; -const url = `http://127.0.0.1:${PORT}`; - -server.listen(PORT, common.mustCall(() => { +server.listen(0, common.mustCall(() => { + const { port } = server.address(); + const url = `http://127.0.0.1:${port}`; http.get(url, common.mustCall(() => { server.close(common.mustCall(() => { - server.listen(PORT, common.mustCall(() => { + server.listen(port, common.mustCall(() => { http.get(url, common.mustCall(() => { server.close(common.mustCall(() => { setTimeout(common.mustCall(verify), 200);