Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Function Uncaught Exceptions - Do They Cause a Cold Start?

Likely an easy question for somebody in the know...

I was reading the documentation for Firebase Cloud Functions and GCP Cloud Functions and I noticed that there is a difference in the recommended approach for handling errors. This surprised me because my understanding is that Firebase Cloud Functions are very closely related to GCP Cloud Functions.

In the Firebase documentation on error reporting it indicates that an error may be thrown to get it into StackDriver, as follows:

throw new Error('Fail!');

Meanwhile, the GCP Cloud Function documentation on error reporting states that uncaught exceptions force a cold start on a future invocation. Instead, the following is suggested:

console.error(new Error('Fail!'));

Does throwing the Error directly also cause a cold start on Firebase Cloud Functions? On Firebase, does sending the error to the console avoid this problem?

Thanks.

like image 298
HondaGuy Avatar asked Oct 19 '25 03:10

HondaGuy


1 Answers

The documentation for Cloud is correct. At this moment, the Firebase docs need to be updated to match the changes that were made for Cloud.

An instance will be restarted after a function throws 3 exceptions. It's likely in your best interest to catch after every then chain, and log the error with console.error().

like image 172
Doug Stevenson Avatar answered Oct 20 '25 20:10

Doug Stevenson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!