From b060866fc73f9b881a89ae2c045e2d484479dbaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Joseph?= Date: Wed, 4 Dec 2019 14:53:11 +0100 Subject: [PATCH 1/3] Require https-proxy-agent only when actually needed --- packages/node/src/transports/http.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/node/src/transports/http.ts b/packages/node/src/transports/http.ts index 7761f53e4a35..969b8c48f197 100644 --- a/packages/node/src/transports/http.ts +++ b/packages/node/src/transports/http.ts @@ -1,7 +1,6 @@ import { Event, Response, TransportOptions } from '@sentry/types'; import { SentryError } from '@sentry/utils'; import * as http from 'http'; -import * as HttpsProxyAgent from 'https-proxy-agent'; import { BaseTransport } from './base'; @@ -12,10 +11,12 @@ export class HTTPTransport extends BaseTransport { super(options); this.module = http; const proxy = options.httpProxy || process.env.http_proxy; - this.client = proxy - ? // tslint:disable-next-line:no-unsafe-any - (new HttpsProxyAgent(proxy) as http.Agent) - : new http.Agent({ keepAlive: false, maxSockets: 30, timeout: 2000 }); + if(proxy){ + const HttpsProxyAgent = require('https-proxy-agent'); + this.client = (new HttpsProxyAgent(proxy) as http.Agent); + } else { + this.client = new http.Agent({ keepAlive: false, maxSockets: 30, timeout: 2000 }); + } } /** From 7a39dadbee40c372fdf62f028f69e90843aacc57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Joseph?= Date: Wed, 4 Dec 2019 14:56:25 +0100 Subject: [PATCH 2/3] Require https-proxy-agent only when actually needed --- packages/node/src/transports/https.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/node/src/transports/https.ts b/packages/node/src/transports/https.ts index dea845c96431..7194feb497f9 100644 --- a/packages/node/src/transports/https.ts +++ b/packages/node/src/transports/https.ts @@ -1,7 +1,6 @@ import { Event, Response, TransportOptions } from '@sentry/types'; import { SentryError } from '@sentry/utils'; import * as https from 'https'; -import * as HttpsProxyAgent from 'https-proxy-agent'; import { BaseTransport } from './base'; @@ -12,10 +11,12 @@ export class HTTPSTransport extends BaseTransport { super(options); this.module = https; const proxy = options.httpsProxy || options.httpProxy || process.env.https_proxy || process.env.http_proxy; - this.client = proxy - ? // tslint:disable-next-line:no-unsafe-any - (new HttpsProxyAgent(proxy) as https.Agent) - : new https.Agent({ keepAlive: false, maxSockets: 30, timeout: 2000 }); + if(proxy){ + const HttpsProxyAgent = require('https-proxy-agent'); + this.client = (new HttpsProxyAgent(proxy) as https.Agent); + } else { + this.client = new http.Agent({ keepAlive: false, maxSockets: 30, timeout: 2000 }); + } } /** From edad46317a051f10d4c3207642b8b9f6e7fad544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Joseph?= Date: Wed, 4 Dec 2019 15:16:45 +0100 Subject: [PATCH 3/3] Typo : https instead of http --- packages/node/src/transports/https.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node/src/transports/https.ts b/packages/node/src/transports/https.ts index 7194feb497f9..56046770bc49 100644 --- a/packages/node/src/transports/https.ts +++ b/packages/node/src/transports/https.ts @@ -15,7 +15,7 @@ export class HTTPSTransport extends BaseTransport { const HttpsProxyAgent = require('https-proxy-agent'); this.client = (new HttpsProxyAgent(proxy) as https.Agent); } else { - this.client = new http.Agent({ keepAlive: false, maxSockets: 30, timeout: 2000 }); + this.client = new https.Agent({ keepAlive: false, maxSockets: 30, timeout: 2000 }); } }