Repository navigation
Closed
Labels
Description
Package + Version
-
@sentry/browser -
@sentry/node -
raven-js -
raven-node(raven for node) - other:
Version:
6.13.3
Description
This is related to #3119
When calling captureException with a DOMException the stack trace of the error is lost.
The code at line 76 of eventbuilder.ts currently has a comment:
if (isDOMError(exception as DOMError) || isDOMException(exception as DOMException)) {
// If it is a DOMError or DOMException (which are legacy APIs, but still supported in some browsers)
// then we just extract the name, code, and message, as they don't provide anything else
// https://developer.mozilla.org/en-US/docs/Web/API/DOMError
// https://developer.mozilla.org/en-US/docs/Web/API/DOMException
...Which I believe is incorrect. DOMError is a legacy API but I don't believe DOMException is. According to 3.14.1. DOMException custom bindings it is expected that DOMException should be an instance of Error and have an associated stack trace. I have confirmed that this is the case in current versions of Safari/Edge/Firefox/Chrome. This is not the case in IE11 though.
I am happy to submit a PR to fix this issue but wanted to get some guidance first.
The fixes I've considered so far are:
- Remove the
isDOMExceptioncheck from the above line, but this will not catchDOMExceptions in IE11 (or any other platform where they're not instances ofError). - Move the
if (isError(exception as Error))block before the other checks and remove thecase '[object DOMException]':fromisError. However I'm not sure where elseisErroris used or what the expected behaviour of this function is. - Change the condition on line 76 from
... || isDOMException(exception as DOMException)to... || (isDOMException(exception as DOMException) && !isInstanceOf(exception, Error)).
Activity
AbhiPrasad commentedon Nov 9, 2021
Hey thanks for writing in. A PR would be great, we can help with testing and docs.
fix(browser): Capture stacktrace on `DOMExceptions`, if possible (#4160)
fix(browser): Capture stacktrace on `DOMExceptions`, if possible (#4160)