Google数据存储无声无息(node.js) [英] Google Datastore Silently Failing in Production (node.js)
问题描述
我的当前配置设置为使用包含我的私钥的服务帐户密钥文件。我已检查它有适当的范围(甚至添加更多比我应该只是为了有数据存储所有者权限)。
我已经将应用程序蒸馏到光秃秃的骨头,仍然没有运气。我卡住了,寻找任何建议。
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);}});}}
更新:
尝试了manual_scaling 这里,但似乎没有工作。还发现这篇文章似乎是类似的问题。
这个问题似乎在grpc模块中。使用0.6.0版本的数据存储。这会自动使用旧版本的grpc。该解决方案将适用于计算引擎。但是,您仍然会遇到灵活的环境问题。这是因为当部署灵活的环境时,它将使用有问题的新模块。
另请参阅以下gitHub上的链接:
https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1955
https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1946
请留意这些链接以获得更高的分辨率。
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.
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.
这篇关于Google数据存储无声无息(node.js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!