You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to use firebase emulator to test storage and firestore triggers? #104
Can I start the emulator with firebase emulators:start and still register the python function? My hope is to test both my nodejs and python functions at the same time.
Can I start the emulator with firebase emulators:start and still register the python function? My hope is to test both my nodejs and python functions at the same time.
I'm not very familiar with the firebase emulator, but it seems like it's not possible to start the emulator via firebase emulators:start and specify --functions_emulator. In addition I think the emulated functions would all need to run on the same host/port.
This might be a good question for the firebase-tools tag on Stack Overflow instead -- it doesn't really have anything to do with the Functions Framework at this point.
Activity
di commentedon Jan 12, 2021
Install
firebase-tools:Install the firestore emulator:
Write a basic "background" function:
Install the Functions Framework:
In one terminal, start the Functions Framework (by default this will be on
localhost:8080):In a second terminal, start the emulator (on a different port,
localhost:8081) and tell it which host/port to use for the functions emulator:Register a trigger with the firestore emulator:
Install the Firestore client library (using Python here but it can be any client library):
Write a script to trigger a write:
In a third terminal, trigger a write:
Observe the function being triggered by the emulator in the first terminal:
manuganji commentedon Jan 12, 2021
This is such a detailed reply. Thank you very much @di ! :)
manuganji commentedon Jan 12, 2021
I have 2 more questions.
storagetriggers, correct?firebase emulators:startand still register the python function? My hope is to test both my nodejs and python functions at the same time.di commentedon Jan 12, 2021
Happy to help!
If you mean Cloud Storage for Firebase, correct. From https://firebase.google.com/docs/emulator-suite#feature-matrix:
There's a feature request for this here: firebase/firebase-tools#1738
I'm not very familiar with the firebase emulator, but it seems like it's not possible to start the emulator via
firebase emulators:startand specify--functions_emulator. In addition I think the emulated functions would all need to run on the same host/port.This might be a good question for the
firebase-toolstag on Stack Overflow instead -- it doesn't really have anything to do with the Functions Framework at this point.lfpazmino commentedon Mar 8, 2021
Hi @di
Thanks for guidelines, quite useful. However, I am facing an issue and I hope you can help me out
I followed your step-by-step instructions, but it is not working. When I checked the firebase-debug.log I find these logs:
[debug] [2021-03-08T23:18:40.086Z] Accepted request POST /functions/projects/{project Id}/triggers/Test --> Test {"metadata":{"emulator":{"name":"functions"},"message":"Accepted request POST /functions/projects/{project id}/triggers/Test --> Test"}}
[debug] [2021-03-08T23:18:40.086Z] Could not find key=Test in {}
[debug] [2021-03-08T23:18:40.088Z] RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined {"metadata":{"emulator":{"name":"functions"},"message":{"code":"ERR_HTTP_INVALID_STATUS_CODE"}}}
[debug] [2021-03-08T23:18:40.088Z] [work-queue] {"queueLength":0,"workRunningCount":0}
I think I am missing something about registering the trigger "Test" somewhere, the one is referring to in the PUT endpoint:
http://localhost:8081/emulator/v1/projects/my-project/triggers/Test
Is there any configuration missing?
Thanks in advance!
di commentedon Mar 9, 2021
@lfpazmino Sorry, I can't really help with the Firebase emulator here. This might be a good issue for the https://github.com/firebase/firebase-tools/ repo or a question for the
firebase-toolstag on Stack Overflow instead.