Cloud Functions for Firebase killed due to memory limit exceeded

前端 未结 10 1909
天涯浪人
天涯浪人 2021-01-31 01:53

I keep getting a sporadic error from Cloud Functions for Firebase when converting a relatively small image (2mb). When successful, the function only takes about 2000ms or less t

10条回答
  •  爱一瞬间的悲伤
    2021-01-31 02:34

    You can set this from within your Cloud Function file on Firebase.

    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
      });
    

    Take from the docs here: https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation

    Don't forget to then run firebase deploy from your terminal.

提交回复
热议问题