0

I'm using Google Cloud Functions via Firebase and was running into the default one-minute timeout and seeing Function execution took 60000 ms, finished with status: 'error' in my logs.

I found I could modify my runtime/memory from 60s/256mb to 500s/512mb at https://console.cloud.google.com/functions/, but the next time I ran firebase deploy --only functions, it set them back to the original 60s/256mb values.

Is there any way I can modify my code so the deployed function has different runtime/memory defaults? Right now, I'm exporting my function like so:

export const myfunction = functions.pubsub.schedule("*/5 * * * *")
    .timeZone("UTC")
    .onRun(async (context) => {
      await main();
    });

I'm currently on v1 version of functions, and am not running locally

Dr-Bracket
  • 4,299
  • 3
  • 20
  • 28
  • Have you seen the documentation? https://firebase.google.com/docs/functions/manage-functions?gen=1st#set_timeout_and_memory_allocation_2 – Doug Stevenson Aug 02 '23 at 13:16

1 Answers1

0

You have to use runWith() as follows:

export const myfunction = functions.pubsub.schedule("*/5 * * * *")
    .runWith({
      timeoutSeconds: 500,
      memory: "512MB",
    })
    .timeZone("UTC")
    .onRun(async (context) => {
      await main();
    });

The corresponding doc is here.

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121
  • Looks like it's only available on v2 - `TypeError: functions.pubsub.schedule(...).runWith is not a function`. Even on v2, I get `TypeError: onSchedule(...).runWith is not a function` – Dr-Bracket Aug 02 '23 at 13:34
  • No it is available in v1 as well. The syntax in my answer is V1 syntax. V2 syntax is different see the doc I refer to in my answer. You may add your entire `index.js` file to your question in order to check you correctly declared/configured your v1 CF. – Renaud Tarnec Aug 02 '23 at 13:58
  • Hi @Dr-Bracket, did you have time to check, following my last comment? – Renaud Tarnec Aug 03 '23 at 14:44
  • 1
    I couldn't get it working with v1, so I migrated to v2 and used ```javascript export const combineAfDatav2 = onSchedule( { schedule: "*/5 3 * * *", timeoutSeconds: 500, memory: "2GiB", timeZone: "UTC", }, async (context) => { await main(); }); ``` – Dr-Bracket Aug 03 '23 at 21:51