skip to Main Content

For older functions i was able to do this:

functions.runWith({timeoutSeconds: 120, memory: "1GB"})

How do we do this for a 2nd generation https.onCall() function?

There does not seem to be any detailed instruction for this anywhere in Firebase’s documentation other than:

  1. A section here that does not cover https.onCall() functions
  2. A section here that also does not cover https.onCall() functions

This SO reference question is NOT a duplicate given that it does not refer to setting an increase for the timeout nor the memory for an onCall() function.

I was not able to find any question on SO specific to this exact question.

2

Answers


  1. Chosen as BEST ANSWER

    One solution is to set the increase inside the firebase.json configuration file as follows, whereas FUNCTION_NAME would need to be set to the name of the exported function in my source code:

    export const FUNCTION_NAME = functions.https.onCall( async (request:any) => {

    "functions": [
        {
          "source": "functions",
          "codebase": "default",
          "ignore": [
            "node_modules",
            ".git",
            "firebase-debug.log",
            "firebase-debug.*.log"
          ],
          "predeploy": [
            "npm --prefix "$RESOURCE_DIR" run lint",
            "npm --prefix "$RESOURCE_DIR" run build"
          ],
          "v2": {
            "source": "functions",
            "runtime": "nodejs16",
            "api_version": 2,
            "endpoints": {
              "FUNCTION_NAME": {
                "platform": "gcfv2",
                "region": "us-central1",
                "availableMemoryMb": 1024,
                "timeoutSeconds": 120
              }
            }
          }
        }
      ],
    

  2. It seems it is possible to simply set both as the first argument of onCall() although i am not able to find this in Firebase’s documentation:

    export const FUNCTION_NAME = functions.https.onCall({timeoutSeconds: 120, memory: "2GiB"}, async (request:any) => {

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search