5

When I am importing more than 300 record in firebase using google cloud function than am getting error :

  • Error: function crashed out of request scope Function killed.
  • Function execution took 31903 ms, finished with status: 'connection error'

3 Answers 3

11

Without a glimpse into your code, I only can guess. "Function crashed outside of request scope" indicates that the cloud function had finished before the asynchronous function(s) did. See for documentation for handling async functions and promises: https://firebase.google.com/docs/functions/terminate-functions

Take a closer look at your returns. Make sure you don't forget to return the promise to functions. For an example see also here: https://github.com/firebase/firebase-functions/issues/18#issuecomment-288375709

Sign up to request clarification or add additional context in comments.

3 Comments

My Cloud Function logs of async functions always show the function finishing first, then the async promises coming back.
@ThomasDavidKehoe 1) The order in the logfiles are not always right. Check the timestamp. 2) When I check the logfiles on the firebase console (Functions logs) the output of asynchronous calls are always coming between "Function execution started" and "Function execution took x ms...". If this is not the case, I'd suggest to check all async calls (maybe use Promis.all if you have more than one) if you really pass them back. Else In my experimental experience cloud functions might work or timeout.
That single line "Make sure to return the promise." helped me
1

I had the same problem and it ended up being a problem with the mysql connection I was using in the project.

In this case I used https://www.npmjs.com/package/mysql2 and the system was losing connections to the database.

It was not clear where it was happening and I got the following errors and no indication where the problem was occurring. - Error: function crashed out of request scope Function killed. - Function execution took 31903 ms, finished with status: 'connection error'

Placing try..catch around the database calls revealed the correct error and location where it was happening.

Comments

-1

Yout might have gone passed a limit, please look at https://firebase.google.com/docs/database/usage/limits.

If this is the case, you could use multiple databases.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.