-
Notifications
You must be signed in to change notification settings - Fork 21
Mutating global.fetch
causes issues with other libraries
#113
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
Comments
@wilsonzlin thanks for the issue -- Cohere uses Fern to generate their SDKs and we'll be making a change to our generator to fix this! |
I've encountered the same issue with global node-fetch after many hours of debugging. @dsinghvi how can this issue be completely resolved? Thank you! |
Hey both, this issues should be resolved in 7.7.4 please let me know if it doesn't fix! |
Hey @hoantran-it super grateful to you for reporting this. We p0'd a fix and 7.7.5 should now be good. We are going to add e2e testing to improve stability of this. Thanks for all of your patience. |
@billytrend-cohere thank you! It works well now 🥳 |
It appears that this library changes
global.fetch
if the globalfetch
does not exist. This causes issues with some other libraries that try to do the same thing, and also overrides the builtinfetch
now available in Node.js; in general, mutating globals from a library is not ideal. For example, this caused all fetch calls from the Oracle Cloud SDK to fail, which I have also raised an issue for. As a side note, it also assumes that the platform is Node.js.Might I suggest using fetch-ponyfill, which provides the same cross-browser fetch polyfill but doesn't mutate the global fetch function? It requires an import, but this should be trivial to migrate to as I found only one call to
fetch
in this library. Alternatively, perhaps create a local variable likeconst fetchFn = typeof fetch == "function" ? fetch : require("node-fetch")
and usefetchFn
instead of mutatingglobal.fetch
.The text was updated successfully, but these errors were encountered: