错误:4 DEADLINE_EXCEEDED:Object.exports.createStatusError 已超过最后期限 - GCP [英] Error: 4 DEADLINE_EXCEEDED: Deadline Exceeded at Object.exports.createStatusError - GCP

查看:21
本文介绍了错误:4 DEADLINE_EXCEEDED:Object.exports.createStatusError 已超过最后期限 - GCP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的一个 Google Cloud Functions 中创建一个 Google Cloud 任务.当一个新对象添加到我的 Cloud Storage 存储分区之一时,此函数会被触发.

I am trying to create a google cloud task from one of my Google Cloud Functions. This function gets triggered when a new object is added to one of my Cloud Storage buckets.

我按照此处提供的说明创建了我的 App Engine(App Engine 快速入门指南)

I followed the instructions given here to create my App Engine (App Engine Quickstart Guide)

然后在我的云函数中,我添加了以下代码来创建云任务(如此处所述 - 创建 App Engine 任务)

Then in my Cloud Function, I added the following code to create a cloud task (as described here - Creating App Engine Tasks)

但是,我的任务或 App Engine 调用有问题(不确定是什么).

However, there is something wrong with my task or App Engine call (not sure what).

我时不时地收到以下错误.有时有效,有时无效.

I am getting the following errors every now and then. Sometimes it works and sometimes it does not.

{ Error: 4 DEADLINE_EXCEEDED: Deadline Exceeded at Object.exports.createStatusError (/srv/node_modules/grpc/src/common.js:91:15) at Object.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:1204:28) at InterceptingListener._callNext (/srv/node_modules/grpc/src/client_interceptors.js:568:42) at InterceptingListener.onReceiveStatus (/srv/node_modules/grpc/src/client_interceptors.js:618:8) at callback (/srv/node_modules/grpc/src/client_interceptors.js:845:24) code: 4, metadata: Metadata { _internal_repr: {} }, details: 'Deadline Exceeded' }

如果您需要更多信息,请告诉我,我将在此处将它们添加到此问题中.

Do let me know if you need more information and I will add them to this question here.

推荐答案

我在firestore遇到了同样的问题,尝试一次写一个文档;我通过返回全部承诺来解决它.那是因为云函数需要知道什么时候方便终止函数,但是如果你不返回任何东西可能会导致这个错误.

I had the same problem with firestore, trying to write one doc at time; I solve it by returning the total promise. That is because cloud function needs to know when is convenient to terminate the function but if you do not return anything maybe cause this error.

我的例子:

data.forEach( d => {
       reports.doc(_date).collection('data').doc(`${d.Id}`).set(d);
    }) 

这是我的问题,我正在逐一编写文档,但我没有兑现承诺.所以我解决了这个问题:

This was the problem with me, I was writing document 1 by 1 but I wasn't returning the promise. So I solve it doing this:

const _datarwt = [];

data.forEach( d => {
          _datarwt.push( reports.doc(_date).collection('data').doc(`${d.Id}`).set(d) );
        }) 
const _dataloaded = await Promise.all( _datarwt );

我将返回的 Promise 保存在一个数组中并等待所有的 Promise.这为我解决了它.希望对您有所帮助.

I save the returned promise in an array and await for all the promises. That solved it for me. Hope been helpful.

这篇关于错误:4 DEADLINE_EXCEEDED:Object.exports.createStatusError 已超过最后期限 - GCP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆