bugsnag-js
bugsnag-js copied to clipboard
TypeError: undefined is not an object (evaluating 'this["BS~~U"].replace')
Describe the bug
After updating to the last version we started to receive a lot of identical errors in bugsnag web app from different parts of our application - TypeError: undefined is not an object (evaluating 'this["BS~~U"].replace')

I investigated a bit and found that this commit from 16 Jun is causing this error https://github.com/bugsnag/bugsnag-js/commit/ece06354bd8c6d402ee79db81663f746e6fe7e0c#diff-9b5eddef7819dd0f66be05dc7119868c717bc9c1f93622f446ddbf88ab72ce41R63
Environment
- Bugsnag version: 7.11.0
- Browser framework version (if any):
- Angular: 11.2.14 Reproducable on different browsers
Error messages:
Error · TypeError: undefined is not an object (evaluating 'this["BS~~U"].replace')
Hi @olehleskiv
Thanks for the detailed report - we're taking a look.
Hi @olehleskiv,
I've fixed the crash in #1564, which should go out in the next release. However, this error means something about the XMLHttpRequest
object isn't quite right and will prevent network breadcrumbs being collected
It'd be good to figure out what is causing this to happen so that it's possible to collect network breadcrumbs in your app. Are you using another library that monkey patches XMLHttpRequest
? How do you make network requests in your application?
To elaborate on the cause of this error:
We patch the open
method and attach the URL to the XMLHttpRequest
instance. The URL can then be read from the same instance in handleXHRLoad
Something is causing the URL to go missing, which implies the XMLHttpRequest
instance has been modified between the call to open
and the load event firing. It shouldn't be possible for the URL to be missing in any other circumstance as handleXHRLoad
will only be called after open
is, because we attach the event listener in open