diff --git a/lib/https.js b/lib/https.js index d8b42c85493f7e..6de78f454e165a 100644 --- a/lib/https.js +++ b/lib/https.js @@ -350,7 +350,7 @@ Agent.prototype._evictSession = function _evictSession(key) { delete this._sessionCache.map[key]; }; -const globalAgent = new Agent({ keepAlive: true, scheduling: 'lifo', timeout: 5000 }); +let globalAgent = new Agent({ keepAlive: true, scheduling: 'lifo', timeout: 5000 }); /** * Makes a request to a secure web server. @@ -415,9 +415,21 @@ function get(input, options, cb) { module.exports = { Agent, - globalAgent, Server, createServer, get, request, }; + +// make https.globalAgent overridable also under ECMAScript Modules +ObjectDefineProperty(module.exports, 'globalAgent', { + __proto__: null, + configurable: true, + enumerable: true, + get() { + return globalAgent; + }, + set(value) { + globalAgent = value; + }, +});