Skip to content

Commit eab7b32

Browse files
committed
fix: handle xhr responseText exception
1 parent cbc69b8 commit eab7b32

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/otel-web/src/HyperDXXMLHttpRequestInstrumentation.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ export class HyperDXXMLHttpRequestInstrumentation extends XMLHttpRequestInstrume
6666
span,
6767
(header) => headers[header],
6868
);
69-
span.setAttribute('http.response.body', xhr.responseText);
69+
try {
70+
span.setAttribute('http.response.body', xhr.responseText);
71+
} catch (e) {
72+
// ignore (DOMException if responseType is not the empty string or "text")
73+
}
7074

7175
shimmer.unwrap(xhr, 'setRequestHeader');
7276
shimmer.unwrap(xhr, 'send');

0 commit comments

Comments
 (0)