8000 ref(replay): Add further logging to network body parsing (#9566) · alexgleason/sentry-javascript@5698094 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5698094

Browse files
authored
ref(replay): Add further logging to network body parsing (getsentry#9566)
We got somewhat closer to figuring out the problem there. Based on this comment: getsentry#9339 (comment) > The requests are now showing with the request body, but the response body is "undefined" It seems that the problem is with parsing the response body for a XHR request. I added some more logging there, to be able to debug this further.
1 parent e4cd09c commit 5698094

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

packages/replay/src/coreHandlers/util/networkUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ export function getBodyString(body: unknown): string | undefined {
7878
__DEBUG_BUILD__ && logger.warn('[Replay] Failed to serialize body', body);
7979
}
8080

81+
__DEBUG_BUILD__ && logger.info('[Replay] Skipping network body because of body type', body);
82+
8183
return undefined;
8284
}
8385

packages/replay/src/coreHandlers/util/xhrUtils.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,24 @@ function getResponseHeaders(xhr: XMLHttpRequest): Record<string, string> {
135135
}
136136

137137
function _getXhrResponseBody(xhr: XMLHttpRequest): string | undefined {
138+
// We collect errors that happen, but only log them if we can't get any response body
139+
const errors: unknown[] = [];
140+
138141
try {
139142
return xhr.responseText;
140-
} catch {} // eslint-disable-line no-empty
143+
} catch (e) {
144+
errors.push(e);
145+
}
141146

142147
// Try to manually parse the response body, if responseText fails
143148
try {
144149
const response = xhr.response;
145150
return getBodyString(response);
146-
} catch {} // eslint-disable-line no-empty
151+
} catch (e) {
152+
errors.push(e);
153+
}
154+
155+
__DEBUG_BUILD__ && logger.warn('[Replay] Failed to get xhr response body', ...errors);
147156

148157
return undefined;
149158
}

0 commit comments

Comments
 (0)
0