Firebase-functions: version 2.0.0 causes timeout everywhere

Created on 25 Jul 2018  路  12Comments  路  Source: firebase/firebase-functions

Hi,
Today I upgrade firebase functions from 1.1.0 to 2.0.0 and deploy using exactly the same index.js
but all my 22 functions are now timeout every time and everywhere. (almost none is success)

untitled

after one hour, I rolled back a version in package.json to 1.1.0 and re-deploy ,everything is back to normal now.

this is extremely scary for me since my project is on production right now.
any suggestion what i am doing wrong?

thanks
Paul

Most helpful comment

Thanks for the report everyone. I was able to reproduce the error, and it seems that the function does all of its work successfully and then doesn't terminate in time. I will work on a fix. Thanks for the patience!

All 12 comments

Hi Paul, did you by any chance update your runtime to Node 8 by changing your functions/package.json? And if you wouldn't mind, could you share the code for one of your functions?

And are you using any Firestore-triggered functions, we have a breaking change in v2.0.0 for timestamp values.

Hi @laurenzlong,
Yes, I do using a firestore-trigger functions.
I have already changed the timestamp values by adding a setting to it but not sure if it is correct.

did you by any chance update your runtime to Node 8 by changing your functions/package.json?

not sure, could you please advise how to check?

thanks for a nice support

I am getting the same issue. I am using auth.user().onCreate & auth.user().onDelete functions to create using profile documents in firestore. For some reason both functions end with a timeout and don't end cleanly even though the functions are able to successfully create the document in firestore

Here are my functions:

export const createNewUserProfile = auth.user().onCreate(async ({ uid }) => {
  const db = admin.firestore()
  const collection = db.collection("/userProfiles")
  const doc = collection.doc(`${uid}`)

  try {
    await doc.set({})
  } catch (e) {
    throw new Error(e.message)
  }
})

export const deleteUserProfile = auth.user().onDelete(async ({ uid }) => {
  const db = admin.firestore()
  const collection = db.collection("/userProfiles")
  const doc = collection.doc(`${uid}`)

  try {
    await doc.delete()
  } catch (e) {
    throw new Error(e.message)
  }
})

Thanks for everything in advance!

Edit 1: I made sure I am specifically running and deploying the code with node 6.14.0.
_Function log:_

deleteUserProfile | Function execution took 60002 ms, finished with status: 'timeout'
deleteUserProfile | Function execution started

Edit 2: For async/await, I am using async-to-gen. For es6 modules, I am using esm

Edit 3: The timeout problem seems to be isolated to node 6. I deployed with node 8 and the function end with an ok status

I've discovered this as well. With v2.0 a Storage triggered function, such as the one below, will reach the 60s timeout every time. However, downgrading to v1.1.0 it works normally.

exports.StorageSignal = functions.storage.object().onFinalize((object, context) => {
  console.log(JSON.stringify(object));
  console.log(JSON.stringify(context));
  return null;
})

Previously mentioned this here: https://groups.google.com/forum/#!topic/firebase-talk/anIs6a5AaYo

I've also confirmed that adding "engines": {"node": "8"} to package.json has _no_ effect (previously I had no 'engines' definition).

Yes, I've been seeing the same thing, I reported to support yesterday afternoon and provided the below example proving the issue. It's not Firestore, but seems to be any Event with the exception of Http.

Super basic example below:

exports.brokenFunction = Functions.pubsub.topic('run-broken-function')
    .onPublish((data, context) => {
        return delayPromise(3000)
            .then(() => {
                console.log("Delayed promise completed")
                return
            })
    })

function delayPromise(duration) {
    return new Promise((resolve) => setTimeout(resolve,duration))
}

I had the same problem with timeout, but adding

"engines": {
"node": "8"
}

to functions/package.json

solved my problem.

Greetings

Thanks for the report everyone. I was able to reproduce the error, and it seems that the function does all of its work successfully and then doesn't terminate in time. I will work on a fix. Thanks for the patience!

Hi everyone, this has now been fixed in v2.0.1, apologies for the convenience, thanks for the helpful details everyone!

I have the same issue, now using firebase-functions 2.0.5. Suddenly, all my functions started to timeout, but I am not sure if this started after I updated.

If someone can help me, I would be thankful:

https://stackoverflow.com/questions/51993927/firebase-functions-now-timeout/51998411?noredirect=1#comment90981993_51998411

[email protected] same problem with Blaze plan..

Was this page helpful?
0 / 5 - 0 ratings