bugsnag-js icon indicating copy to clipboard operation
bugsnag-js copied to clipboard

TypeError: undefined is not an object (evaluating 'this["BS~~U"].replace')

Open olehleskiv opened this issue 3 years ago • 3 comments

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')

Screenshot at Nov 02 23-50-54

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')

olehleskiv avatar Nov 02 '21 21:11 olehleskiv

Hi @olehleskiv

Thanks for the detailed report - we're taking a look.

mattdyoung avatar Nov 03 '21 00:11 mattdyoung

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

imjoehaines avatar Nov 03 '21 14:11 imjoehaines

Hi @olehleskiv - just to let you know we released a fix for this in v7.13.3 of bugsnag-js 🎉

We'd still be interested to hear any thoughts you had in response to Joe's comment above!

luke-belton avatar Nov 10 '21 00:11 luke-belton