Google Datastore Silently Failing in Production (n

2019-06-10 05:32发布

问题:

As part of a larger web app, I'm using a combination of Google Datastore and Firebase. On my local machine, all requests go through seamlessly, however when I deploy my app to the GAE (using node.js - Flexible Environment) everything works except the calls to the datastore. The requests do not throw an error, directly or via promise and just never return, hanging the process.

My current configuration is set up to use a Service Account key file containing my private key. Ive checked that it has the proper scope (and even added more than i should just in case to have Datastore Owner permissions).

I've distilled the app down to the bare bones, and still no luck. I'm stuck and looking for any suggestions.

const datastore = require( '@google-cloud/datastore' );

const config = require( 'yaml-config' )
    .readConfig( 'config.yaml' );

module.exports = {

get_test: function(query, callback) {

  var ds_ref = datastore({
    projectId: config.DATASTORE_PROJECT,
    keyFilename: __dirname + config.GOOGLE_CLOUD_KEY
  });

  var q = ds_ref.createQuery('comps')
    .filter('record', query.record);

  ds_ref.runQuery(q, function(err, entities) {

    if (!err) {
      if (entities.length > 0) {
        callback(err, entities[0]);
      } else {
        callback(err, []);
      }
    } else {
      callback(err, undefined);
    }
  });

}

}

UPDATE:

Tried manual_scaling found here but didn't seem to work. Also found this article that seems to be a similar issue.

回答1:

The problem seems to be in the grpc module. Use 0.6.0 version of datastore. This will automatically use an older version of grpc. The solution will work for compute engine. However you will still face problems with the flexible environment. This is because when the flexible environment is deployed, it will use the new modules which have the problem.

Also please refer to the following links on gitHub: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1955 https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1946

Please keep a watch of these links for an update in resolution.