Skip to content

Commit

Permalink
http: refactor to use min of validateNumber for maxTotalSockets
Browse files Browse the repository at this point in the history
Remove duplicate implementation by using min of validateNumber.
  • Loading branch information
deokjinkim committed Jan 6, 2023
1 parent 0593b69 commit d596c69
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 1 addition & 4 deletions lib/_http_agent.js
Expand Up @@ -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;
}
Expand Down
2 changes: 0 additions & 2 deletions test/parallel/test-http-agent-maxtotalsockets.js
Expand Up @@ -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}`,
});
});

Expand Down

0 comments on commit d596c69

Please sign in to comment.