diff --git a/.changeset/spicy-cherries-reflect.md b/.changeset/spicy-cherries-reflect.md new file mode 100644 index 00000000..ddc2ab85 --- /dev/null +++ b/.changeset/spicy-cherries-reflect.md @@ -0,0 +1,5 @@ +--- +'@hyperdx/otel-web': patch +--- + +fix: handle xhr responseText exception diff --git a/packages/otel-web/src/HyperDXXMLHttpRequestInstrumentation.ts b/packages/otel-web/src/HyperDXXMLHttpRequestInstrumentation.ts index 7d1c6cae..49266ace 100644 --- a/packages/otel-web/src/HyperDXXMLHttpRequestInstrumentation.ts +++ b/packages/otel-web/src/HyperDXXMLHttpRequestInstrumentation.ts @@ -66,7 +66,11 @@ export class HyperDXXMLHttpRequestInstrumentation extends XMLHttpRequestInstrume span, (header) => headers[header], ); - span.setAttribute('http.response.body', xhr.responseText); + try { + span.setAttribute('http.response.body', xhr.responseText); + } catch (e) { + // ignore (DOMException if responseType is not the empty string or "text") + } shimmer.unwrap(xhr, 'setRequestHeader'); shimmer.unwrap(xhr, 'send');