Skip to content

Commit fdf1424

Browse files
committed
fix(): prevent the keep alive flag from completely overwriting an existing https agent configuration
1 parent da57d59 commit fdf1424

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/util/BaseRestClient.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,16 @@ export default abstract class BaseRestClient {
7878

7979
// If enabled, configure a https agent with keepAlive enabled
8080
if (this.options.keepAlive) {
81+
// Extract existing https agent parameters, if provided, to prevent the keepAlive flag from overwriting an existing https agent completely
82+
const existingHttpsAgent = this.globalRequestOptions.httpsAgent as
83+
| https.Agent
84+
| undefined;
85+
const existingAgentOptions = existingHttpsAgent?.options || {};
86+
8187
// For more advanced configuration, raise an issue on GitHub or use the "networkOptions"
8288
// parameter to define a custom httpsAgent with the desired properties
8389
this.globalRequestOptions.httpsAgent = new https.Agent({
90+
...existingAgentOptions,
8491
keepAlive: true,
8592
keepAliveMsecs: this.options.keepAliveMsecs,
8693
});

0 commit comments

Comments
 (0)