lquixada / cross-fetch

Universal WHATWG Fetch API for Node, Browsers and React Native.
MIT License
1.66k stars 102 forks source link

fix: use existing fetch if it exists, otherwise fallback to whatwg-fetch #138

Closed ThisIsMissEm closed 1 year ago

ThisIsMissEm commented 2 years ago

I'm not sure why the code was written the way it is, but it appears to be forcing the polyfill to be used even in environments where the Fetch API exists natively, which isn't intentional and causes the bugs described in #91, #78, and #69.

The original commit and PR don't describe why the behaviour was changed: https://github.com/lquixada/cross-fetch/commit/123b1a2ef13f279f444118398959fb3424abfca4

ThisIsMissEm commented 2 years ago

This will need a build done on this branch, since you're committing the build artifacts to the repo too.

firehudson commented 1 year ago

Is there any update on the above PR @ThisIsMissEm @jpwilliams ?

ThisIsMissEm commented 1 year ago

Is there any update on the above PR @ThisIsMissEm @jpwilliams ?

We're ditching cross-fetch for our own package that works for our use case better, it'll be released soon.

jaredpalmer commented 1 year ago

Any updates here? This is blocking a lot of AI Provider's SDKs from working on Vercel and Cloudflare Workers.

ThisIsMissEm commented 1 year ago

Any updates here? This is blocking a lot of AI Provider's SDKs from working on Vercel and Cloudflare Workers.

My former employer, Inrupt, has released a replacement called @inrupt/universal-fetch which is designed to use native fetch if it exists (doesn't polyfill for older browsers), but will use native node.js 18+ fetch, or uses undici in node.js 16 (same as the new native fetch) or finally node-fetch in node 14.

edit: I'm not sure if it's fetch detection will work 100% out of the box on Cloudflare Workers or Vercel Functions, but I think it should, and they'd probably appreciate patches if it doesn't work on those platforms.

Might be worth a look.

lquixada commented 1 year ago

hi @ThisIsMissEm. thanks for taking the time to work on this PR. I'm closing this in favor of #163 .