diff --git a/package.json b/package.json index 9e35f8dc..5e49b521 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ "scripts": { "build": "rm -fr ./dist && NODE_ENV=production babel ./src --out-dir ./dist --copy-files --source-maps && flow-copy-source src dist", "create-readme": "gitdown ./.README/README.md --output-file ./README.md", + "dev": "NODE_ENV=development babel ./src --out-dir ./dist --copy-files --source-maps --watch", "lint": "eslint ./src ./test && flow", "test": "NODE_ENV=test nyc ava --verbose --serial" }, diff --git a/src/factories/createGlobalProxyAgent.js b/src/factories/createGlobalProxyAgent.js index 37b4be4e..05d10aff 100644 --- a/src/factories/createGlobalProxyAgent.js +++ b/src/factories/createGlobalProxyAgent.js @@ -96,25 +96,37 @@ export default (configurationInput: ProxyAgentConfigurationInputType = defaultCo return proxyController.HTTP_PROXY; }; - const httpAgent = new HttpProxyAgent( - isProxyConfigured(getHttpProxy), - mustUrlUseProxy(getHttpProxy), - getUrlProxy(getHttpProxy), - http.globalAgent, - eventEmitter - ); + const BoundHttpProxyAgent = class extends HttpProxyAgent { + constructor () { + super( + isProxyConfigured(getHttpProxy), + mustUrlUseProxy(getHttpProxy), + getUrlProxy(getHttpProxy), + http.globalAgent, + eventEmitter + ); + } + }; + + const httpAgent = new BoundHttpProxyAgent(); const getHttpsProxy = () => { return proxyController.HTTPS_PROXY || proxyController.HTTP_PROXY; }; - const httpsAgent = new HttpsProxyAgent( - isProxyConfigured(getHttpsProxy), - mustUrlUseProxy(getHttpsProxy), - getUrlProxy(getHttpsProxy), - https.globalAgent, - eventEmitter - ); + const BoundHttpsProxyAgent = class extends HttpsProxyAgent { + constructor () { + super( + isProxyConfigured(getHttpsProxy), + mustUrlUseProxy(getHttpsProxy), + getUrlProxy(getHttpsProxy), + https.globalAgent, + eventEmitter + ); + } + }; + + const httpsAgent = new BoundHttpsProxyAgent(); // Overriding globalAgent was added in v11.7. // @see https://nodejs.org/uk/blog/release/v11.7.0/