[go: nahoru, domu]

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

[FR] - Firebase Admin Lite #2572

Open
jdgamble555 opened this issue May 27, 2024 · 14 comments
Open

[FR] - Firebase Admin Lite #2572

jdgamble555 opened this issue May 27, 2024 · 14 comments

Comments

@jdgamble555
Copy link

Is your feature request related to a problem? Please describe.
Currently Firebase cannot run on Deno, Cloudflare, Vercel Edge, or Bun (among others). Firebase will mainly be used in Node Serverless environments with Cold Starts, which are unacceptable for many app developers.

Describe the solution you'd like
If you don't require Authentication, you can use the "Firestore Lite" package. However, we cannot use Authentication or the Server Functions in order to keep our session. This is a HUGE problem and limits where Firebase can be deployed.

Describe alternatives you've considered
Using the REST API. However, it is EXTREMELY cumbersome in order to convert JSON data to the data types that REST API uses, as well as the problems handling tokens etc.

Additional context

It would be nice to be able to use the FirebaseServerApp as well, but this would not have ALL the features we may need in other JS environments.

J

@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@dconeybe
Copy link

@jdgamble555 Thank you for raising this issue. Could you elaborate on the use case where the preferRest option (as noted in #1879) does not solve your issue?

@jdgamble555
Copy link
Author

Yes, this will not solve the problem as "Edge" computing cannot load packages like "fs", "stream", "child_process", "crypto", "os", etc... This are usually items that are required with grpc, protobuf protocol etc... but NOT with REST API.

J

@jdgamble555
Copy link
Author

setting preferRest still loads these items

@dconeybe
Copy link

Ok I think I see what you're saying. Could you mention which Firebase products specifically would be useful to you in a "lite" SDK? You mentioned Firestore for one. Also, would you prefer a "tree-shakeable" API (like https://github.com/firebase/firebase-js-sdk) or an object-oriented API (like https://github.com/firebase/firebase-admin-node)?

In any case, this is a pretty big undertaking so I have no promises as to if, or when, such a product will become available. But it's helpful to gather yours (and others') requirements for a time when we decide to scope such a project.

@dconeybe
Copy link

Also, could you describe how you would envision authentication to work? Authentication in the firebase-node-admin SDK in non-google edge computing environments would likely need an "exported service account key file" (https://firebase.google.com/docs/admin/setup) and these environments often do not have access to the file system. Would it work, for example, to be able to specify the JSON contents of the key file rather than a path to the key file? Then, at runtime, the code would need to first obtain the key file from some other place (e.g. d1/kv/r2 in cloudflare workers) and specify it to the initialization function for Firebase.

@jdgamble555
Copy link
Author

Here is how I setup my Firebase Admin app now. I use the environment variables.

Firestore already has a "lite" version that works with the REST API. It will work on non-node runtimes. However, it is only Firestore (not Firebase Auth etc) so you can't use an authentication token nor fetch data behind Firestore Rules.

Here is an example of a package that tries to mimic what Firebase Admin should already do.

https://github.com/Moe03/firebase-admin-rest

I have seen enough of these packages built over the years, that they never keep up-to-date. This is how it should work out-of-the-box IMO.

Imagine:

import { getAuth } from 'firebase-admin/auth/lite';
import { getFirestore } from 'firebase-admin/firestore/lite';

Similar to how the frontend works.

J

@dconeybe
Copy link

@jdgamble555 Thank you for the explanation and the example from @Moe03. I've logged b/343978422 internally to track this feature request and will keep you apprised of developments. But TBH it's unlikely that this feature request will see much progress without more requests from the community. For anyone who would like to see this feature, please reply with a brief explanation of your use case to help us prioritize this!

@ganey
Copy link
ganey commented Jun 3, 2024

Wow this is still an ongoing issue? (i got the notification from the previous one with GRPC slow init)

iirc last time i used the admin sdk, preferRest was firebase/firestore only, so making one call to do an admin function meant the request took about 8 seconds in cloud functions/aws lambda.

If your doing firebase auth with a backend like php (no firebase sdk), then you could be using a node based admin app to handle this, and loading the admin sdk was just always slow.

8 seconds for a user is just ridiculous, and the early solutions such as 'function keep alive / warmers' are really not dev friendly...

'oh hey our sdk is massive and takes a while to load, so spend more money with us keeping your code cached and it'll be fast'.

Sorry if i come across annoyed by this, but I had many issues with firebase over the years from bad/missing/stale docs, to issues like this just taking forever to get fixed.

@Rizzist
Copy link
Rizzist commented Jun 5, 2024

hoping new firebase admin lite works on edge
when compiling regularly it works,
but when compiling for edge I get this error:
Module not found: Can't resolve './build/Debug/farmhash.node'

^guessing its a firebase dependency?

@kulterryan
Copy link

how to use it with Bun?

@dconeybe
Copy link

Note that this repository specifically targets node (the name is firebase-admin-node). Providing a version that works portably across JavaScript runtimes (e.g. deno, bun, cloudflare workers) is a significant undertaking to create and maintain long-term and not something that is prioritized at the moment. That being said, please continue to voice your interest in such an SDK so that we can get a sense of the customer demand for this feature. Thanks everyone!

@jdgamble555
Copy link
Author

@dconeybe - To be fair, it was built for Node before other Runtimes were popular and probably named to differentiate between go, python etc.

It would be advantageous to build a "lite" version, just like firebase-js-sdk has, as it could speed up NodeJS loading times as well. I don't think you would need to rebuild the whole package, just allow more tree-shaking and less dependency needs per package. If you imported from firebase-admin/lite for example, it would not import all the bulk package dependencies etc.

J

@dconeybe
Copy link

@jdgamble555 Thank you for your input. I don't disagree that there is value in providing a version that is decoupled from node.js. It's just a matter of prioritization.

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

8 participants