Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: 4 DEADLINE_EXCEEDED: Deadline Exceeded at Object.exports.createStatusError - GCP

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.

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

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

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.

like image 529
nasaa Avatar asked Mar 08 '19 16:03

nasaa


1 Answers

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.

My example:

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 );

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

like image 62
Chaotic Pechan Avatar answered Oct 17 '22 17:10

Chaotic Pechan