File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -189,21 +189,16 @@ export class NodeTransport implements Transport {
189
189
* @internal
190
190
*/
191
191
private agentForTransportRequest ( req : TransportRequest ) : HttpAgent | HttpsAgent | undefined {
192
- // Don't configure any agents if keep alive not requested.
193
- if ( ! this . keepAlive && ! this . proxyConfiguration ) return undefined ;
194
-
195
192
// Create proxy agent (if possible).
196
193
if ( this . proxyConfiguration )
197
194
return this . proxyAgent ? this . proxyAgent : ( this . proxyAgent = new ProxyAgent ( this . proxyConfiguration ) ) ;
198
195
199
196
// Create keep alive agent.
200
197
const useSecureAgent = req . origin ! . startsWith ( 'https:' ) ;
201
198
202
- if ( useSecureAgent && this . httpsAgent === undefined )
203
- this . httpsAgent = new HttpsAgent ( { keepAlive : true , ...this . keepAliveSettings } ) ;
204
- else if ( ! useSecureAgent && this . httpAgent === undefined ) {
205
- this . httpAgent = new HttpAgent ( { keepAlive : true , ...this . keepAliveSettings } ) ;
206
- }
199
+ const agentOptions = { keepAlive : this . keepAlive , ...( this . keepAlive ? this . keepAliveSettings : { } ) } ;
200
+ if ( useSecureAgent && this . httpsAgent === undefined ) this . httpsAgent = new HttpsAgent ( agentOptions ) ;
201
+ else if ( ! useSecureAgent && this . httpAgent === undefined ) this . httpAgent = new HttpAgent ( agentOptions ) ;
207
202
208
203
return useSecureAgent ? this . httpsAgent : this . httpAgent ;
209
204
}
You can’t perform that action at this time.
0 commit comments