From 71059fbfa531f0229ca70a23c0082cec7315d6b4 Mon Sep 17 00:00:00 2001 From: Eugene Ostroukhov Date: Tue, 24 Apr 2018 11:16:55 -0700 Subject: [PATCH] inspector: Use default uv_listen backlog size PR-URL: https://github.com/nodejs/node/pull/20254 Reviewed-By: Rich Trott Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Ben Noordhuis Reviewed-By: Ali Ijaz Sheikh Reviewed-By: Trivikram Kamat --- src/inspector_socket_server.cc | 3 +- test/parallel/test-inspector-stress-http.js | 34 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-inspector-stress-http.js diff --git a/src/inspector_socket_server.cc b/src/inspector_socket_server.cc index 3725c19e93fb86..e69c8d768be156 100644 --- a/src/inspector_socket_server.cc +++ b/src/inspector_socket_server.cc @@ -587,7 +587,8 @@ int ServerSocket::Listen(InspectorSocketServer* inspector_server, CHECK_EQ(0, uv_tcp_init(loop, server)); int err = uv_tcp_bind(server, addr, 0); if (err == 0) { - err = uv_listen(reinterpret_cast(server), 1, + // 511 is the value used by a 'net' module by default + err = uv_listen(reinterpret_cast(server), 511, ServerSocket::SocketConnectedCallback); } if (err == 0) { diff --git a/test/parallel/test-inspector-stress-http.js b/test/parallel/test-inspector-stress-http.js new file mode 100644 index 00000000000000..4787c35e32c899 --- /dev/null +++ b/test/parallel/test-inspector-stress-http.js @@ -0,0 +1,34 @@ +// Flags: --expose-internals +'use strict'; +const common = require('../common'); + +common.skipIfInspectorDisabled(); + +const assert = require('assert'); +const { NodeInstance } = require('../common/inspector-helper.js'); + +async function testHttp(child, number) { + try { + await child.httpGet(null, '/json/list'); + return true; + } catch (e) { + console.error(`Attempt ${number} failed`, e); + return false; + } +} + +async function runTest() { + const child = new NodeInstance(undefined, ''); + + const promises = []; + for (let i = 0; i < 100; i++) { + promises.push(testHttp(child, i)); + } + const result = await Promise.all(promises); + assert(!result.some((a) => !a), 'Some attempts failed'); + return child.kill(); +} + +common.crashOnUnhandledRejection(); + +runTest();