@@ -70,7 +70,7 @@ function _fetchResponseHandler(
70
70
requestInfo : RequestInfo ,
71
71
response : Response ,
72
72
requestInit ?: RequestInit ,
73
- stack ?: string ,
73
+ error ?: unknown ,
74
74
) : void {
75
75
if ( _shouldCaptureResponse ( options , response . status , response . url ) ) {
76
76
const request = _getRequest ( requestInfo , requestInit ) ;
@@ -90,7 +90,7 @@ function _fetchResponseHandler(
90
90
responseHeaders,
91
91
requestCookies,
92
92
responseCookies,
93
- stacktrace : stack ,
93
+ error ,
94
94
} ) ;
95
95
96
96
captureEvent ( event ) ;
@@ -129,7 +129,7 @@ function _xhrResponseHandler(
129
129
xhr : XMLHttpRequest ,
130
130
method : string ,
131
131
headers : Record < string , string > ,
132
- stack ?: string ,
132
+ error ?: unknown ,
133
133
) : void {
134
134
if ( _shouldCaptureResponse ( options , xhr . status , xhr . responseURL ) ) {
135
135
let requestHeaders , responseCookies , responseHeaders ;
@@ -162,7 +162,7 @@ function _xhrResponseHandler(
162
162
// Can't access request cookies from XHR
163
163
responseHeaders,
164
164
responseCookies,
165
- stacktrace : stack ,
165
+ error ,
166
166
} ) ;
167
167
168
168
captureEvent ( event ) ;
@@ -292,14 +292,14 @@ function _wrapFetch(client: Client, options: HttpClientOptions): void {
292
292
return ;
293
293
}
294
294
295
- const { response, args } = handlerData ;
295
+ const { response, args, error } = handlerData ;
296
296
const [ requestInfo , requestInit ] = args as [ RequestInfo , RequestInit | undefined ] ;
297
297
298
298
if ( ! response ) {
299
299
return ;
300
300
}
301
301
302
- _fetchResponseHandler ( options , requestInfo , response as Response , requestInit , handlerData . stack ) ;
302
+ _fetchResponseHandler ( options , requestInfo , response as Response , requestInit , error ) ;
303
303
} , false ) ;
304
304
}
305
305
@@ -327,7 +327,7 @@ function _wrapXHR(client: Client, options: HttpClientOptions): void {
327
327
const { method, request_headers : headers } = sentryXhrData ;
328
328
329
329
try {
330
- _xhrResponseHandler ( options , xhr , method , headers , handlerData . stack ) ;
330
+ _xhrResponseHandler ( options , xhr , method , headers , handlerData . error ) ;
331
331
} catch ( e ) {
332
332
DEBUG_BUILD && logger . warn ( 'Error while extracting response event form XHR response' , e ) ;
333
333
}
@@ -362,13 +362,12 @@ function _createEvent(data: {
362
362
responseCookies ?: Record < string , string > ;
363
363
requestHeaders ?: Record < string , string > ;
364
364
requestCookies ?: Record < string , string > ;
365
- stacktrace ?: string ;
365
+ error ?: unknown ;
366
366
} ) : SentryEvent {
367
367
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 ;
369
369
// Remove the first frame from the stack as it's the HttpClient call
370
370
const stack = virtualStackTrace && client ? client . getOptions ( ) . stackParser ( virtualStackTrace , 0 , 1 ) : undefined ;
371
-
372
371
const message = `HTTP Client Error with status code: ${ data . status } ` ;
373
372
374
373
const event : SentryEvent = {
0 commit comments