From d596c695f35afc63fc64cd78853993e29dd6541b Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Fri, 6 Jan 2023 11:52:21 +0900 Subject: [PATCH] http: refactor to use min of validateNumber for maxTotalSockets Remove duplicate implementation by using min of validateNumber. --- lib/_http_agent.js | 5 +---- test/parallel/test-http-agent-maxtotalsockets.js | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 14096361760657..b4a560b09df36c 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -125,10 +125,7 @@ function Agent(options) { validateOneOf(this.scheduling, 'scheduling', ['fifo', 'lifo']); if (this.maxTotalSockets !== undefined) { - validateNumber(this.maxTotalSockets, 'maxTotalSockets'); - if (this.maxTotalSockets <= 0 || NumberIsNaN(this.maxTotalSockets)) - throw new ERR_OUT_OF_RANGE('maxTotalSockets', '> 0', - this.maxTotalSockets); + validateNumber(this.maxTotalSockets, 'maxTotalSockets', 1); } else { this.maxTotalSockets = Infinity; } diff --git a/test/parallel/test-http-agent-maxtotalsockets.js b/test/parallel/test-http-agent-maxtotalsockets.js index c44c8db627d330..fce1bf8de83144 100644 --- a/test/parallel/test-http-agent-maxtotalsockets.js +++ b/test/parallel/test-http-agent-maxtotalsockets.js @@ -20,8 +20,6 @@ assert.throws(() => new http.Agent({ }), { code: 'ERR_OUT_OF_RANGE', name: 'RangeError', - message: 'The value of "maxTotalSockets" is out of range. ' + - `It must be > 0. Received ${item}`, }); });