Description
The isomorphic-fetch dependency mutates the global fetch
value. This causes problems with some other libraries that also do this in some other way. For example, all fetch
calls from this SDK failed when I loaded the cohere-ai library, which also mutates global.fetch
(I have raised an issue there too).
It appears that this isn't necessary, as the fetch
call is only used in 2 places (excluding examples) across the entire codebase: circuit-breaker.ts and http.ts. These can be trivially migrated to using an imported fetch
(see below) that avoids mutating the global value, which is actually already done in url-based-x509-certificate-supplier.ts.
Also, the dependence on both isomorphic-fetch
and node-fetch
appears to be redundant (the former loads the latter on Node.js). I would suggest replacing both with fetch-ponyfill instead, which is recommended by the authors of isomorphic-fetch; it doesn't mutate the builtin, and provides both whatwg-fetch
for browsers and node-fetch
for Node.js. (It appears that node-fetch is also only used in 1 place.)