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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Cloudflare Workers / Vercel Edge Functions #2032

Open
kelbyfaessler opened this issue Oct 17, 2023 · 3 comments
Open

Support Cloudflare Workers / Vercel Edge Functions #2032

kelbyfaessler opened this issue Oct 17, 2023 · 3 comments

Comments

@kelbyfaessler
Copy link

馃殌 Feature Proposal

This client doesn't currently work in apps deployed on cloudflare workers and Vercel edge functions because these environments don't support all node APIs, and your client uses some of these unsupported APIs. It would be nice if there was either a more minimal client without these dependencies, or if we had the option to not install some client features in order to remove these dependencies.

Motivation

These deployment options are becoming increasingly popular and you'll probably increasingly have people asking about it. For example, here's an issue where a couple people were discussing this problem and the only solution was to abandon the client and make raw HTTP requests instead.

Example

Here are some of the unsupported nodejs APIs:

  • url
  • os
  • assert
  • util
  • stream
  • events
  • worker_threads
  • diagnostics_channel
  • async_hooks
  • perf_hooks
  • http
  • net
  • zlib
  • console
  • tls
  • net
  • querystring
  • http
  • https

Here is where they occur in the client (via my build/deploy errors):

  • lib/sniffingTransport
  • lib/client
  • lib/Diagnostic
  • lib/Serializer
  • lib/pool/BaseConnectionPool
  • transport/lib/transport
  • .... many others

But is all of this stuff really necessary for a client that's a wrapper around a REST API? Or if so, could I opt into only the things I actually need so I don't need to bundle all this stuff in my build?

@JoshMock
Copy link
Member

Thanks for listing out all of those unsupported areas of the code, @kelbyfaessler. Super helpful when addressing requests like this.

At present, support for edge workers isn't on our short-term roadmap, but we have put some similar items on the list for consideration. Deno support came up in #1742, where the request is to decouple the client from core Node.js APIs.

As requests like this come in, our justification for prioritizing the work to do this will definitely grow.

ping @srikanthmanvi for visibility

@johnomeara1
Copy link

This is definitely needed! With server-side-rendering systems like Nuxt or Next, people rely on edge functions to connect to elastic search.

Unrelated Complaint: I spent the last week building my Nuxt application using this library, only to find out when I deploy, nothing works because it doesn't have support for cloudflare workers. It was also a debugging nightmare because the error messages were cryptic. It took me around 3 hours to finally realize that this library does not support edge functions. Now, I have to rewrite everything using painful HTTP requests...

@JoshMock
Copy link
Member

@johnomeara1 Can you give some hints as to how this failed on Nuxt? Perhaps there's an opportunity to at least make the errors more useful until we can add edge support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants