File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -114,10 +114,13 @@ AWS.NodeHttpClient = AWS.util.inherit({
114
114
AWS . NodeHttpClient . sslAgent = new https . Agent ( { rejectUnauthorized : true } ) ;
115
115
AWS . NodeHttpClient . sslAgent . setMaxListeners ( 0 ) ;
116
116
117
- // delegate maxSockets to globalAgent
117
+ // delegate maxSockets to globalAgent, set a default limit of 50 if current value is Infinity.
118
+ // Users can bypass this default by supplying their own Agent as part of SDK configuration.
118
119
Object . defineProperty ( AWS . NodeHttpClient . sslAgent , 'maxSockets' , {
119
120
enumerable : true ,
120
- get : function ( ) { return https . globalAgent . maxSockets ; }
121
+ get : function ( ) {
122
+ return https . globalAgent . maxSockets !== Infinity ? https . globalAgent . maxSockets : 50 ;
123
+ }
121
124
} ) ;
122
125
}
123
126
return AWS . NodeHttpClient . sslAgent ;
Original file line number Diff line number Diff line change @@ -9,10 +9,17 @@ if AWS.util.isNode()
9
9
it ' delegates maxSockets from agent to globalAgent' , ->
10
10
https = require (' https' )
11
11
agent = http .sslAgent ()
12
+ https .globalAgent .maxSockets = 5
12
13
expect (https .globalAgent .maxSockets ).to .equal (agent .maxSockets )
13
14
https .globalAgent .maxSockets += 1
14
15
expect (https .globalAgent .maxSockets ).to .equal (agent .maxSockets )
15
16
17
+ it ' overrides globalAgent value if global is set to Infinity' , ->
18
+ https = require (' https' )
19
+ agent = http .sslAgent ()
20
+ https .globalAgent .maxSockets = Infinity
21
+ expect (agent .maxSockets ).to .equal (50 )
22
+
16
23
describe ' handleRequest' , ->
17
24
it ' emits error event' , (done ) ->
18
25
req = new AWS.HttpRequest ' http://invalid'
You can’t perform that action at this time.
0 commit comments