Search code examples
firebasefirebase-tools

How to configure timeout of Firebase functions on local


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?


Solution

  • 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