Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop monkeyPatching fetch API #660

Closed
lifeiscontent opened this issue Dec 3, 2019 · 6 comments
Closed

stop monkeyPatching fetch API #660

lifeiscontent opened this issue Dec 3, 2019 · 6 comments

Comments

@lifeiscontent
Copy link

lifeiscontent commented Dec 3, 2019

No description provided.

@bengourley
Copy link
Contributor

It's the only way to track network requests as breadcrumbs, since the browser doesn't offer an event for it.

You can switch this off with the networkBreadcrumbsEnabled option if it is having undesirable side-effects.

@sassomedia
Copy link

@bengourley The networkBreadcrumbsEnabled options does not work, network-breadcrumbs.js is still loaded. What can be done about this? 3rd-party libraries really should not alter native objects.

Using v6 of Bugsnag, btw.

@xljones
Copy link

xljones commented Sep 25, 2020

@sassomedia, in v7 this option looks slightly different: https://docs.bugsnag.com/platforms/javascript/configuration-options/#enabledbreadcrumbtypes

Use:

Bugsnag.start({ 
  enabledBreadcrumbTypes: ['error', 'log', 'navigation', 'user']
})

Omitting 'request' from this list.

@sassomedia
Copy link

@xander-jones Thanks for the quick reply, although I don't see this working either. v6 used to have a bugsnagClient setup and that's basically what we have, simplified example here: https://codepen.io/sassomedia/pen/GRZegrB.

That console.log(fetch) in the example should output ƒ fetch() { [native code] } but I'm always getting the monkey-patch. Is there something else I'm missing? Thanks!

@xljones
Copy link

xljones commented Sep 25, 2020

@sassomedia, sorry made an error in my comment above, this is for v7 🙈. I've amended my comment above. For v6, this would be the following option: https://docs.bugsnag.com/platforms/javascript/legacy/configuration-options/#networkbreadcrumbsenabled-browser-only.

I think the issue you're seeing is that you're changing the Bugsnag config after instantiating Bugsnag, so at this point fetch() has already been patched.

If you use the following, you can use Bugsnag, and we won't be patching fetch():

var bugsnagClient = bugsnag({
  apiKey: 'cdd848e5d2da0a26bda6f31a42452428',
  networkBreadcrumbsEnabled: false
});
window.bugsnagClient = bugsnagClient;
console.log(fetch);

Results in:

ƒ fetch() { [native code] }

@sassomedia
Copy link

@xander-jones Ah ok, yes that makes sense. Works for me, thanks a bunch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants