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

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

Closed
wants to merge 1 commit into from

Conversation

ThisIsMissEm
Copy link

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: 123b1a2

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 lquixada#91, lquixada#78, and lquixada#69.

The original commit and PR don't describe why the behaviour was changed: lquixada@123b1a2
@ThisIsMissEm
Copy link
Author

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

@ThisIsMissEm ThisIsMissEm changed the title Use existing fetch if it exists, otherwise fallback to whatwg-fetch fix: use existing fetch if it exists, otherwise fallback to whatwg-fetch May 26, 2022
bahlo added a commit to axiomhq/next-axiom that referenced this pull request Jun 24, 2022
We import it conditionally anyway and cross-fetch has an issue where
it's used even in environments where fetch exists natively, see
lquixada/cross-fetch#138
bahlo added a commit to axiomhq/next-axiom that referenced this pull request Jun 25, 2022
We import it conditionally anyway and cross-fetch has an issue where
it's used even in environments where fetch exists natively, see
lquixada/cross-fetch#138
bahlo added a commit to axiomhq/next-axiom that referenced this pull request Jun 28, 2022
We import it conditionally anyway and cross-fetch has an issue where
it's used even in environments where fetch exists natively, see
lquixada/cross-fetch#138
@firehudson
Copy link

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

@ThisIsMissEm
Copy link
Author

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.

njerig added a commit to njerig/rate-my-professors that referenced this pull request Apr 3, 2023
isomorphic-fetch uses the same browser polyfill as cross-fetch and
therefore returns the same error. isomorphic-fetch will be removed
as a dependency in the next commit.

Related pull request that was never merged: lquixada/cross-fetch#138
@jaredpalmer
Copy link

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

@ThisIsMissEm
Copy link
Author

ThisIsMissEm commented Apr 18, 2023

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 lquixada force-pushed the main branch 2 times, most recently from c7aa351 to 5e3d301 Compare April 23, 2023 22:32
@lquixada
Copy link
Owner

lquixada commented May 7, 2023

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

@lquixada lquixada closed this May 7, 2023
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

Successfully merging this pull request may close these issues.

4 participants