firebase-functions
firebase-functions copied to clipboard
Firebase function logging duplicate errors on failure
Could anyone help me understand if this is a bug or expected? When i try to fail a firestore trigger function i see the same error show up 2 times with different timestamps.
Cloud Logging

Code
exports.func = functions
.firestore
.document('stuffs/{stuffid}')
.onWrite((snap, context) => {
return Promise.reject(new Error("I'm just returning a rejected promise"));
});
My End goal is:
- Log to error log using functions.logger.error
- Report error to error reporting
- Force a retry of the function since an error occured that is most likely temporal in nature
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
@TraGicCode Thanks for raising the issue!
I'm going to poke at some internal folks to see if I can get an answer to the duplicate log issue.
On the other hand, I think there are some complication in Google Cloud Function not handling promise rejections very well. This will certainly lead to container shutdown and thus introduce more cold starts to your service. I suggest handling errors on client side as much as possible - you may also see the duplicate error disappear w/ those changes.
Hey @taeold ,
For the comment on retries, When an error occurs I want a retry to occur. This is because there could be a bug or some transient outage.
if there is a transient outage the retry will eventually succeed and no manual intervention will be required.
If there is a bug, I want the retries to continue and an alert to fire. This will allow a developer to resolve the issue and deploy a fix.
If I stop the retries ( by catching and swallowing the error? ) then the event is loss and now I have something that needs to happen that never happened which is not ideal.
in regards to the duplicate log issue, could this be related to the fire base functions framework doing something that is doing this?