Weilies
Weilies

Reputation: 530

Firebase Cloud Function Deployment - Invalid Memory Property

My firebase cloud function (TypeScript) has included the runtimeOption by referring to official doc https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation

const runtimeOpts = {
  timeoutSeconds: 540,
  memory: "1GB"
}
..
export const GCPSpeech2TranscriptLRR = functions.runWith(runtimeOpts).https.onRequest((req, res) => {

It returns deployment error

src/index.ts:145:58 - error TS2345: Argument of type '{ timeoutSeconds: number; memory: string; }' is not assignable to parameter of type 'RuntimeOptions'.
  Types of property 'memory' are incompatible.
    Type 'string' is not assignable to type '"128MB" | "256MB" | "512MB" | "1GB" | "2GB" | undefined'.

145 export const GCPSpeech2TranscriptLRR = functions.runWith(runtimeOpts).https.onRequest((req, res) => {

I have tried both memory: "1GB", memory: '1GB' but yet i get the same error. If i removed the 'memory : ...' line,it will deploy correctly. Even after the CF deployed successfully, it still return error below within 2 mins. From what i awared, the code supposed to run for 9mins

Subscriber.js:192 Error: deadline-exceeded
    at new HttpsErrorImpl (index.cjs.js:58)
    at index.cjs.js:373
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
    at push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask (zone.js:503)
    at ZoneTask.invoke (zone.js:492)
    at timer (zone.js:3034)

Upvotes: 2

Views: 921

Answers (2)

Sinisa Vrhovac
Sinisa Vrhovac

Reputation: 11

This one worked for me:

memory: "2GB" as const,

Upvotes: 1

David
David

Reputation: 654

This looks like an issue with the Typescript compiler's inference. Try with:

memory: "1GB" as "1GB"

Upvotes: 10

Related Questions