简体   繁体   English

是什么导致 GCP Cloud Functions 响应错误?

[英]What causes a GCP Cloud Functions response error?

I have a GCP Cloud Function which is triggered via a Pub/sub topic.我有一个通过发布/订阅主题触发的 GCP 云 Function。 The function just backs up Datastore data to Cloud storage. function 只是将 Datastore 数据备份到 Cloud storage。 The function works fine but I get a function 工作正常,但我得到一个
Function execution took 933 ms. Finished with status: response error Function execution took 933 ms. Finished with status: response error and I don't understand why? Function execution took 933 ms. Finished with status: response error ,我不明白为什么? As far as I understand I follow what is in the GCP Docs .据我所知,我遵循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编辑 1完整的错误消息是: 2022-04-09T10:30:15.076043374Z test-chron-handler yuthy3qj84sr Function execution took 933 ms. Finished with status: response error 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. 2022-04-09T10:30:15.076043374Z test-chron-handler yuthy3qj84sr Function execution took 933 ms. Finished with status: response error实际上它甚至没有在 Cloud Functions 日志中标记为错误,它只是一条常规状态消息,记录 function 结束。 But as you can see the finishing status is indeed an error.但是正如你所看到的,完成状态确实是一个错误。

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.当 function 返回除 200 以外的任何内容时,这似乎是当前已知的问题。甚至 201 和 204 也会在日志中给出响应错误。 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 GCP 日志显示 function 每当我的 header 状态代码不是 200 时,“函数执行花费了 xxx 毫秒。完成状态:响应错误”

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 – Priyashree Bhadra 4 月 19 日 11:02

This issue happens when the response size from the functions exceeds 10MB 1 .当函数的响应大小超过 10MB 1时,会发生此问题。 I think you hit the max response size which is 10 MB for functions.我认为您达到了最大响应大小,即函数的 10 MB。

For more information please go through these stackoverflow links 2 & 3 .如需更多信息,请通过这些 stackoverflow 链接23拨打 go。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以在 GCP 中通过云功能或云运行来触发云内存存储? - Is it possible to trigger cloud memorystore by cloud functions or cloud run in GCP? 如何在 GCP 中的云 function 中执行两个功能? - how to execute two functions in a cloud function in GCP? gcp 云函数访问 gcp 存储桶是否有成本 - Is there a cost for gcp cloud functions to access gcp storage buckets 无法将 GCP 秘密管理器与 GCP 云功能(nodeJS)一起使用 - not able to use GCP secret-manager with GCP cloud functions(nodeJS) GCP Cloud Functions with spring cloud function and spring native - GCP Cloud Functions with spring cloud function and spring native 如何将 Firestore 侦听器功能部署到 GCP Cloud? - How to deploy Firestore listener functions to GCP Cloud? GCP Cloud Functions:Node.JS 版本路线图 - GCP Cloud Functions: Node.JS Versions Roadmap 为什么 GCP Cloud Functions 会记录两个空行? - Why does GCP Cloud Functions log two blank lines? GCP Cloud Functions Gen 2 - 无法通过 NodeJs 或 gcloud 调用 - GCP Cloud Functions Gen 2 - Cannot call through NodeJs or gcloud 在 GCP 云功能中添加跨项目服务帐户 - Adding cross project service account in GCP cloud functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM