Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud functions for firebase - finished with status: 'timeout' - info not error

If a cloud function times out, I would like to have that as an error in the logs, so I can track the health of the functions, and if necessary take steps to improve speeds.

Is it possible to make that log to show as an error?

Also, is there a way to catch such timeout? I have a function that if an exception is thrown, saves something to the realtime-database. Is it possible to catch this error as well?

Firebase Response:

Thank you for reaching out, and for providing your feedback to us. I'm Kyle from Firebase Support and I'll be happy to handle this case regarding Cloud Functions with Firebase.

I understood that Cloud Function timeouts should be regarded as "errors" instead of "info" logs. I also agree that having another trigger that responds to timeout events like functions.onTimeout() would be very cool to be included in the future version of Cloud Functions.

For this, please note that I've cascaded your feedback (and use-case) about treating function timeouts as an error log, and not as an info log. I've also filed an internal feature request ticket for your suggestion of having functions.onTimeout() trigger. This will be processed to be discussed internally within the team, but I can't provide any ETAs or specific timeline as to when this requested feature will be implemented. In the meantime, you may keep an eye on our release notes and Firebase blog for upcoming features and bug fixes that Firebase offers to our valued developers.

like image 408
Amit Avatar asked Dec 13 '18 23:12

Amit


2 Answers

I figured out a workaround to accomplish this.

I used Google Cloud Functions tools to monitor timeouts of my Firebase Cloud Functions.

I set up a custom alert whenever "finished with status: 'timeout'" is logged by any of my functions:

I went over to https://console.cloud.google.com/logs/viewer and created a custom advanced search:

resource.type="cloud_function"
"finished with status: 'timeout'"

Then, I used the "Create Metric" feature to track instances of that log.

Then under https://console.cloud.google.com/logs/metrics, I found my user-defined metric and created a custom alert for it.

like image 175
Charlie Avatar answered Oct 05 '22 05:10

Charlie


When a function times out, you will see a line in the logs for that. Are you suggesting that you don't see it?

You can't catch timeouts. This is a hard restriction of Cloud Functions that prevents your code from running away outside of its control.

like image 38
Doug Stevenson Avatar answered Oct 05 '22 06:10

Doug Stevenson