@@ -70,7 +70,7 @@ function _fetchResponseHandler(
7070 requestInfo : RequestInfo ,
7171 response : Response ,
7272 requestInit ?: RequestInit ,
73- stack ?: string ,
73+ error ?: unknown ,
7474) : void {
7575 if ( _shouldCaptureResponse ( options , response . status , response . url ) ) {
7676 const request = _getRequest ( requestInfo , requestInit ) ;
@@ -90,7 +90,7 @@ function _fetchResponseHandler(
9090 responseHeaders,
9191 requestCookies,
9292 responseCookies,
93- stacktrace : stack ,
93+ error ,
9494 } ) ;
9595
9696 captureEvent ( event ) ;
@@ -129,7 +129,7 @@ function _xhrResponseHandler(
129129 xhr : XMLHttpRequest ,
130130 method : string ,
131131 headers : Record < string , string > ,
132- stack ?: string ,
132+ error ?: unknown ,
133133) : void {
134134 if ( _shouldCaptureResponse ( options , xhr . status , xhr . responseURL ) ) {
135135 let requestHeaders , responseCookies , responseHeaders ;
@@ -162,7 +162,7 @@ function _xhrResponseHandler(
162162 // Can't access request cookies from XHR
163163 responseHeaders,
164164 responseCookies,
165- stacktrace : stack ,
165+ error ,
166166 } ) ;
167167
168168 captureEvent ( event ) ;
@@ -292,14 +292,14 @@ function _wrapFetch(client: Client, options: HttpClientOptions): void {
292292 return ;
293293 }
294294
295- const { response, args } = handlerData ;
295+ const { response, args, error } = handlerData ;
296296 const [ requestInfo , requestInit ] = args as [ RequestInfo , RequestInit | undefined ] ;
297297
298298 if ( ! response ) {
299299 return ;
300300 }
301301
302- _fetchResponseHandler ( options , requestInfo , response as Response , requestInit , handlerData . stack ) ;
302+ _fetchResponseHandler ( options , requestInfo , response as Response , requestInit , error ) ;
303303 } , false ) ;
304304}
305305
@@ -327,7 +327,7 @@ function _wrapXHR(client: Client, options: HttpClientOptions): void {
327327 const { method, request_headers : headers } = sentryXhrData ;
328328
329329 try {
330- _xhrResponseHandler ( options , xhr , method , headers , handlerData . stack ) ;
330+ _xhrResponseHandler ( options , xhr , method , headers , handlerData . error ) ;
331331 } catch ( e ) {
332332 DEBUG_BUILD && logger . warn ( 'Error while extracting response event form XHR response' , e ) ;
333333 }
@@ -362,13 +362,12 @@ function _createEvent(data: {
362362 responseCookies ?: Record < string , string > ;
363363 requestHeaders ?: Record < string , string > ;
364364 requestCookies ?: Record < string , string > ;
365- stacktrace ?: string ;
365+ error ?: unknown ;
366366} ) : SentryEvent {
367367 const client = getClient ( ) ;
368- const virtualStackTrace = client && data . stacktrace ? data . stacktrace : undefined ;
368+ const virtualStackTrace = client && data . error && data . error instanceof Error ? data . error . stack : undefined ;
369369 // Remove the first frame from the stack as it's the HttpClient call
370370 const stack = virtualStackTrace && client ? client . getOptions ( ) . stackParser ( virtualStackTrace , 0 , 1 ) : undefined ;
371-
372371 const message = `HTTP Client Error with status code: ${ data . status } ` ;
373372
374373 const event : SentryEvent = {
0 commit comments