I want to do some intense job on firebase functions and it usually takes more than 60 seconds. On production, I can set timeout longer from web console but I cannot find setting for local environment.
Following is the command which I'm using to start serving.
firebase serve --only functions
I'm using HTTPS trigger and following is the command to trigger my function on local.
functions-emulator call myfunc --data='{"uid":"user_id_1"}'
Is there way to configure timeout on local?
The Firebase Local Emulator Suite is a set of advanced tools for developers looking to build and test apps locally using Cloud Firestore, Realtime Database, Cloud Storage, Authentication, Cloud Functions, Pub/Sub, Firebase Hosting and Firebase Extensions.
You can set the timeout and memory options in local using the RunWith function
const runtimeOpts = {
timeoutSeconds: 300,
memory: '1GB'
}
exports.myStorageFunction = functions
.runWith(runtimeOpts)
.storage
.object()
.onFinalize((object) = > {
// do some complicated things that take a lot of memory and time
});
The maximum value for timeoutSeconds is 540, or 9 minutes. Valid values for memory are:
128MB
256MB
512MB
1GB
2GB
I struggled with this for a while, but finally found this solution:
.env.local
FUNCTIONS_EMULATOR_TIMEOUT_SECONDS=540s
.env.local
file should be honored.h/t to volkyeth for the related GitHub firebase issue response: https://github.com/firebase/firebase-tools/issues/2837#issuecomment-1048878134
There is a known issue with the Firebase emulator ignoring runWith({timeoutSeconds: }) when running Firebase functions locally.
Until Firebase fixes this, @SuttonY's answer provides one solution for changing the timeout setting locally, which is to create an .env.local file.
Another solution is to set the timeout variable in the command line when you run the Firebase emulator. For example, this is the command I use to start my emulator:
FUNCTIONS_EMULATOR_TIMEOUT_SECONDS=540 firebase emulators:start --only functions
Credit to @tiagohillebrandt for finding and posting this on the open GitHub issue. https://github.com/firebase/firebase-tools/issues/2837
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With