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

Support Cloudflare Workers / Vercel Edge Functions #2032

Closed
kelbyfaessler opened this issue Oct 17, 2023 · 5 comments
Closed

Support Cloudflare Workers / Vercel Edge Functions #2032

kelbyfaessler opened this issue Oct 17, 2023 · 5 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

@jsomeara
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.

Copy link
Contributor

This issue is stale because it has been open 90 days with no activity. Remove the stale label, or leave a comment, or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Nov 13, 2024
@JoshMock
Copy link
Member

We determined in #2341 to not pursue this in the short term. I'd like to explore the possibility of a "Web" client that uses only Web APIs and thus supports most edge compute environments. We have also discussed the potential of e.g. providing a WASM build of the new Rust client as it reaches maturity, possibly providing JS bindings for it.

@JoshMock JoshMock closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2024
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

4 participants