Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/replay/src/coreHandlers/util/networkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export function getBodyString(body: unknown): string | undefined {
__DEBUG_BUILD__ && logger.warn('[Replay] Failed to serialize body', body);
}

__DEBUG_BUILD__ && logger.info('[Replay] Skipping network body because of body type', body);

return undefined;
}

Expand Down
13 changes: 11 additions & 2 deletions packages/replay/src/coreHandlers/util/xhrUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,24 @@ function getResponseHeaders(xhr: XMLHttpRequest): Record<string, string> {
}

function _getXhrResponseBody(xhr: XMLHttpRequest): string | undefined {
// We collect errors that happen, but only log them if we can't get any response body
const errors: unknown[] = [];

try {
return xhr.responseText;
} catch {} // eslint-disable-line no-empty
} catch (e) {
errors.push(e);
}

// Try to manually parse the response body, if responseText fails
try {
const response = xhr.response;
return getBodyString(response);
} catch {} // eslint-disable-line no-empty
} catch (e) {
errors.push(e);
}

__DEBUG_BUILD__ && logger.warn('[Replay] Failed to get xhr response body', ...errors);

return undefined;
}