@@ -5,6 +5,7 @@ import { addExtensionMethods, Span, TRACEPARENT_REGEXP, Transaction } from '@sen
55import { parseSemver } from '@sentry/utils' ;
66import * as http from 'http' ;
77import * as https from 'https' ;
8+ import * as HttpsProxyAgent from 'https-proxy-agent' ;
89import * as nock from 'nock' ;
910
1011import { Breadcrumb } from '../../src' ;
@@ -143,7 +144,7 @@ describe('default protocols', () => {
143144 const key = 'catcatchers' ;
144145 const p = captureBreadcrumb ( key ) ;
145146
146- let nockProtocol = 'https: ' ;
147+ let nockProtocol = 'https' ;
147148 // NOTE: Prior to Node 9, `https` used internals of `http` module, so
148149 // the integration doesn't patch the `https` module. However this then
149150 // causes issues with nock, because nock will patch the `https` module
@@ -160,7 +161,7 @@ describe('default protocols', () => {
160161 // because the latest versions of nock no longer support Node v8 and lower,
161162 // so won't bother dealing with this old Node edge case.
162163 if ( NODE_VERSION . major && NODE_VERSION . major < 9 ) {
163- nockProtocol = 'http: ' ;
164+ nockProtocol = 'http' ;
164165 }
165166 nock ( `${ nockProtocol } ://${ key } .ingest.sentry.io` )
166167 . get ( '/api/123122332/store/' )
@@ -175,4 +176,31 @@ describe('default protocols', () => {
175176 const b = await p ;
176177 expect ( b . data ?. url ) . toEqual ( expect . stringContaining ( 'https://' ) ) ;
177178 } ) ;
179+
180+ it ( 'makes https request over http proxy' , async ( ) => {
181+ const key = 'catcatchers' ;
182+ const p = captureBreadcrumb ( key ) ;
183+ let nockProtocol = 'https' ;
184+
185+ const proxy = 'http://<PROXY_URL>:3128' ;
186+ const agent = new HttpsProxyAgent ( proxy ) ;
187+
188+ if ( NODE_VERSION . major && NODE_VERSION . major < 9 ) {
189+ nockProtocol = 'http' ;
190+ }
191+
192+ nock ( `${ nockProtocol } ://${ key } .ingest.sentry.io` )
193+ . get ( '/api/123122332/store/' )
194+ . reply ( 200 ) ;
195+
196+ https . get ( {
197+ host : `${ key } .ingest.sentry.io` ,
198+ path : '/api/123122332/store/' ,
199+ timeout : 300 ,
200+ agent,
201+ } ) ;
202+
203+ const b = await p ;
204+ expect ( b . data ?. url ) . toEqual ( expect . stringContaining ( 'https://' ) ) ;
205+ } ) ;
178206} ) ;
0 commit comments