jola
jola

Reputation: 1115

What causes a GCP Cloud Functions response error?

I have a GCP Cloud Function which is triggered via a Pub/sub topic. The function just backs up Datastore data to Cloud storage. The function works fine but I get a
Function execution took 933 ms. Finished with status: response error and I don't understand why? As far as I understand I follow what is in the GCP Docs.

My code looks like this:

/* receives pub/sub message which is triggered every 24h. 
*/
exports.subscribe = async (message, context) => {
    console.log('CHRON HANDLER STARTED');
    await this.backupDB();
    return Promise.resolve();
}

const bucket = 'gs://XXX_db_backups';

exports.backupDB = async () => {
    try {
        const databaseName = client.databasePath('XXX', '(default)');
        await client.exportDocuments({
            name: databaseName,
            outputUriPrefix: bucket,
            collectionIds: ['backuptest', ],
        });    
    } catch (error) {
        console.log(error);
    }
    console.log('DB BACKUP SUCCESS');
  };

EDIT 1 The complete error message is: 2022-04-09T10:30:15.076043374Z test-chron-handler yuthy3qj84sr Function execution took 933 ms. Finished with status: response error Actually it is not even flagged as an error in the Cloud Functions log, it is just a regular status message that logs that the function ended. But as you can see the finishing status is indeed an error.

Upvotes: 3

Views: 1670

Answers (2)

Robert Sandberg
Robert Sandberg

Reputation: 8635

It seems like this is a current known issue when a function returns anything but a 200. Even 201 and 204 give response error in the logs. It seems to only affect the logs and not the actual response. I've verified this in my setup.

In this SO question:

GCP logs show function "Function execution took xxx ms. Finished with status: response error" whenever my header status code is not 200

The following comment was written:

The product team is aware of this issue and they have updated today that the change is reverted back, you can expect the previous behavior to be resumed shortly. Let me know if you face any errors after a day or two. – Priyashree Bhadra Apr 19 at 11:02

Upvotes: 4

Sandeep Vokkareni
Sandeep Vokkareni

Reputation: 1685

This issue happens when the response size from the functions exceeds 10MB 1. I think you hit the max response size which is 10 MB for functions.

For more information please go through these stackoverflow links 2 & 3.

Upvotes: 0

Related Questions