Commit 8399967f authored by Caleb Weeks's avatar Caleb Weeks

creating copy of keep alive config to avoid non mutable options issue

parent 1a843384
......@@ -8,6 +8,12 @@ var fs=require("fs");
var _path=require("path");
var mkdirp=require("mkdirp");
const KeepAliveAgent = require("agentkeepalive");
const DefaultKeepAliveConfig = {
maxSockets: 100,
maxFreeSockets: 10,
timeout: 60000, // active socket keepalive for 60 seconds
freeSocketTimeout: 30000, // free socket keepalive for 30 seconds
};
var debug=dbg("SLING:debug");
......@@ -68,18 +74,9 @@ var SlingConnector = module.exports = function(options){
this.hasDerefCapability = options.hasDerefCapability;
this.derefByDefault = options.derefByDefault;
this.invalidPathRegex = options.invalidPathRegex || /undefined|\[object Object\]/;
this.httpRequestAgent = options.httpRequestAgent || new KeepAliveAgent(options.httpAgentKeepAliveConfig || {
maxSockets: 100,
maxFreeSockets: 10,
timeout: 60000, // active socket keepalive for 60 seconds
freeSocketTimeout: 30000, // free socket keepalive for 30 seconds
});
this.httpsRequestAgent = options.httpsRequestAgent || new KeepAliveAgent.HttpsAgent(options.httpsAgentKeepAliveConfig || {
maxSockets: 100,
maxFreeSockets: 10,
timeout: 60000, // active socket keepalive for 60 seconds
freeSocketTimeout: 30000, // free socket keepalive for 30 seconds
});
//need to create copies of the keep alive config (using ...) because that library modifies the options object passed in
this.httpRequestAgent = options.httpRequestAgent || new KeepAliveAgent(options.httpAgentKeepAliveConfig ? {...options.httpAgentKeepAliveConfig} : DefaultKeepAliveConfig);
this.httpsRequestAgent = options.httpsRequestAgent || new KeepAliveAgent.HttpsAgent(options.httpsAgentKeepAliveConfig ? {...options.httpsAgentKeepAliveConfig } : DefaultKeepAliveConfig);
this.hasGetIfExistsCapabililty = options.hasGetIfExistsCapabililty;
this.useGetIfExistsByDefault = options.useGetIfExistsByDefault;
this.inMemoryCache = options.inMemoryCache;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment