I have a cloud function triggered as follows:
functions.storage.bucket(stagingBucketName).object().onChange
The files uploaded there are consistently close to 2MB in size. My function downloads those files from a bucket called the staging bucket, manipulates them, and then uploads the two resulting files (one of which is identical to the original 2MB file, the other of which is about 20kB) to a bucket called the serving bucket.
This function fails often enough that I've turned on retries and turned up runtime in an effort to see what happens. I've attached a sample set of logs. In this:
- Over the course of an hour, the function tries 20 times. Each time is up to 3 minutes long.
- The download fails 9 times. Failure is a connection error, taking 120 seconds. The eleven times it succeeds, it consistently takes 4 seconds from the start of the function to the end of the download, except for once it takes 0.2 seconds (!?).
- The upload fails 10 times. Failure happens with my function timing out, taking about 170 seconds. When it finally succeeds, it takes about 0.7 seconds.
This isn't unique to this particular file; this function has been triggered independently many times, and failed many times.
I'm assuming this isn't expected behaviour. If anyone on the Firebase team wants to dig into this, the project is photos-for-grandma, and the function is actually called checkForPhotoUpload. The buckets are photos-for-grandma-photo-staging and photos-for-grandma-photos. I'm interested in:
1. Why does the download fail so often?
2. Why does the upload fail so often?
3. I might get back to you about the download time, but I'm not yet certain how much of the 4 seconds is download.
Cheers,
Bartholomew