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

platform support #36

Closed
cleve-fauna opened this issue Feb 4, 2023 · 3 comments
Closed

platform support #36

cleve-fauna opened this issue Feb 4, 2023 · 3 comments
Assignees

Comments

@cleve-fauna
Copy link
Contributor

Axios hems us into a limited set of platforms. Re-evaluate http layer dependencies to support platforms including:

Cloudflare, Vercel Edge and Serverless functions, Web Assembly, the Deno runtime, AWS Lambda, Netlify Functions

@cleve-fauna cleve-fauna self-assigned this Feb 4, 2023
@ptpaterson ptpaterson assigned ptpaterson and unassigned cleve-fauna Feb 10, 2023
@mmailaender
Copy link

mmailaender commented Feb 11, 2023

Hi guys,

@breinero shared with me the early access of 'fauna-js'. First of all, I want to say that you're doing an excellent job - I can already feel how much faster we will get with FQL.X!

We're currently integrating fauna-js into Cloudflare Workers and running into the Axios incompatibility problem. So I asked @breinero if you're open to some contributions. He said yes, so here I am ;)

We're currently creating a forked version of fauna-js where we replace Axios with fetch(). Fetch seems to be the best option to achieve support for all the major JS runtimes and providers.

I created a list on the compatibility of fetch():

  WebAPI Node 18 Node 17> Deno Bun
Browser fetch() N/A N/A N/A N/A
Cloudflare Workers fetch() N/A N/A TODO N/A
Vercel Edge (Cloudflare Workers) fetch() N/A N/A TODO N/A
Vercel Serverless functions N/A fetch() Isomorphic Unfetch / Cross-fetch fetch() fetch()
Cloud Functions N/A fetch() Isomorphic Unfetch / Cross-fetch fetch() fetch()
Azure Functions N/A fetch() Isomorphic Unfetch / Cross-fetch fetch() fetch()
AWS Lambda N/A fetch() Isomorphic Unfetch / Cross-fetch fetch() fetch()
Netlify Functions (AWS Lambda) N/A fetch() Isomorphic Unfetch / Cross-fetch fetch() fetch()
Web Assembly TODO TODO TODO TODO TODO

image

Some open points need to be clarified (Eventually, you can answer them?):

  • Deno for Cloudflare Workers: I saw this guide, but I'm not sure if I can force Workers to run Deno under the hood. Both are JS runtimes, so makes not really sense to me. But eventually, it's more like a "pre-transformation"?
  • Web Assembly: I know that you can import the I/O from the parent instance - in that case, fetch() should work, but I'm not 100% sure.

I marked Isomorphic Unfetch & Cross-fetch orange because neither seems the perfect solution. These are the suggested isomorphic libraries by node-fetch but:
Both implement a polyfill of fetch() to be consistent between Node and WebAPI. The polyfill is a subset from fetch(). Isomorphic Unfetch is actively developed but has yet to support streaming. Unfetch | Github

Cross-Fetch, on the other side, supports the WHATWG polyfill that is already more mature developed. But Cross-Fetch is not anymore developed since one year back. Including missing support for Cloudflare Workers. It's a patch available, but to apply it, you need to fork Cross-Fetch and maintain it yourself.

The question is, how impactful do you rate these points? Especially considering that Node 14 has EOL April this year and Node 16 has EOL September this year.


I expect to create a pull request during the upcoming week. To track our progress here:

  • Replace Axios with Fetch
  • Rewrite Tests to work with Fetch
  • Test Isomorphix Unfetch
  • Test Cross-Fetch

@ptpaterson
Copy link
Contributor

@mmailaender Thanks for the awesome writeup!

We are indeed killing axios and need to fill it in with an API that will work for web and Node. We also need to support HTTP2 for efficient connection management and to lay the foundation for server events (i.e. Event Streaming).

Cross-fetch is great, but has problems with platform support like you said (plus no HTTP2).

Node 18 has experimental support for the fetch API. We could use that, but then we couldn't support the current LTS Node version at GA.

We are working on a test suite to make sure our solution is in fact compatible with various platforms. Hopefully we can point this issue at some PRs soon 😉 😄

@mmailaender mmailaender mentioned this issue Feb 14, 2023
6 tasks
@cleve-fauna
Copy link
Contributor Author

This was shipped in #66

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

3 participants