File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -152,9 +152,9 @@ export function normalizeRequestArgs(
152152 // Worst case we end up populating protocol with undefined, which it already is
153153 /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any */
154154 requestOptions . protocol =
155+ ( httpModule ?. globalAgent as any ) ?. protocol ||
155156 ( requestOptions . agent as any ) ?. protocol ||
156- ( requestOptions . _defaultAgent as any ) ?. protocol ||
157- ( httpModule ?. globalAgent as any ) ?. protocol ;
157+ ( requestOptions . _defaultAgent as any ) ?. protocol
158158 /* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any */
159159 }
160160
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { parseSemver } from '@sentry/utils';
66import * as http from 'http' ;
77import * as https from 'https' ;
88import * as nock from 'nock' ;
9+ import * as HttpsProxyAgent from "https-proxy-agent" ;
910
1011import { Breadcrumb } from '../../src' ;
1112import { NodeClient } from '../../src/client' ;
@@ -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} ) ;
You can’t perform that action at this time.
0 commit comments