firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.01k stars 929 forks source link

Run firebase emulators:start --only functions #7335

Closed alexpchin closed 2 months ago

alexpchin commented 3 months ago

[REQUIRED] Environment info

13.3.1

firebase-tools:

macOs

Platform:

[REQUIRED] Test case

[REQUIRED] Steps to reproduce

When running firebase emulators:start --only functions I see: function ignored because the firestore emulator does not exist or is not running.

[REQUIRED] Expected behavior

I would expect to be able to run the emulated functions but connecting to a live firestore database.

[REQUIRED] Actual behavior

It seems like you can only run the functions emulator with the firebstore emulator?

aalej commented 3 months ago

Hey @alexpchin, thanks for reaching out. Let me know if I may be wrong here, but from what I can tell, you’re trying to trigger local functions based on production events. If so, this is not possible. A detailed explanation can be found in https://github.com/firebase/firebase-tools/issues/1962#issuecomment-583498789.

However, if you’re trying to read/write data from/to production, you could use the Firebase Admin SDK.

alexpchin commented 3 months ago

Hello @aalej Please can you re-open. I'm not trying to trigger local functions based on production events. I've got some firebase functions that are callable, http etc. What I want to be able to do is to call the functions from a localhost endpoint but for them to use the production firebase credentials.

This is part of a bigger task of trying to use the emulators within the context of a PR. I believe it should be possible to use the firebase functions locally, so that they are callable but they use a real firestore database in the config.

alexpchin commented 3 months ago

I pretty much want to run as if I'm using:

firebase serve --only functions
aalej commented 3 months ago

Thanks for the clarification @alexpchin. Just to verify, from what I understand you have Firebase Cloud Functions such as an HTTP function. When the function runs, you want to use the same credentials from production as credentials for the Firebase Admin SDK to write data to Cloud Firestore.

Is my understanding here correct, or am I missing anything? Would you be able to share a sample code snippet of your function?

joehan commented 3 months ago

Hey @alexpchin - this message function ignored because the firestore emulator does not exist or is not running. will be shown when the Functions emulator skips over a Firestore triggered function. If you have HTTP or callable functions, they are still running.

google-oss-bot commented 2 months ago

Hey @alexpchin. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 2 months ago

Since there haven't been any recent updates here, I am going to close this issue.

@alexpchin if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.