Skip to content

Commit bdccf52

Browse files
committed
fix: make xhr header parsing safer
1 parent a7f6321 commit bdccf52

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/browser-utils/src/networkUtils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ export function getFetchRequestArgBody(fetchArgs: unknown[] = []): RequestInit['
6060
* Extracted from replay internals to be reusable.
6161
*/
6262
export function parseXhrResponseHeaders(xhr: XMLHttpRequest): Record<string, string> {
63-
const headers = xhr.getAllResponseHeaders();
63+
let headers: string | undefined;
64+
try {
65+
headers = xhr.getAllResponseHeaders();
66+
} catch (error) {
67+
DEBUG_BUILD && debug.exception(error, 'Failed to get xhr response headers');
68+
return {};
69+
}
6470

6571
if (!headers) {
6672
return {};

0 commit comments

Comments
 (0)