Skip to content

Commit d596c69

Browse files
committed
http: refactor to use min of validateNumber for maxTotalSockets
Remove duplicate implementation by using min of validateNumber.
1 parent 0593b69 commit d596c69

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

lib/_http_agent.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,7 @@ function Agent(options) {
125125
validateOneOf(this.scheduling, 'scheduling', ['fifo', 'lifo']);
126126

127127
if (this.maxTotalSockets !== undefined) {
128-
validateNumber(this.maxTotalSockets, 'maxTotalSockets');
129-
if (this.maxTotalSockets <= 0 || NumberIsNaN(this.maxTotalSockets))
130-
throw new ERR_OUT_OF_RANGE('maxTotalSockets', '> 0',
131-
this.maxTotalSockets);
128+
validateNumber(this.maxTotalSockets, 'maxTotalSockets', 1);
132129
} else {
133130
this.maxTotalSockets = Infinity;
134131
}

test/parallel/test-http-agent-maxtotalsockets.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ assert.throws(() => new http.Agent({
2020
}), {
2121
code: 'ERR_OUT_OF_RANGE',
2222
name: 'RangeError',
23-
message: 'The value of "maxTotalSockets" is out of range. ' +
24-
`It must be > 0. Received ${item}`,
2523
});
2624
});
2725

0 commit comments

Comments
 (0)