【发布时间】:2020-04-15 00:40:10
【问题描述】:
我们正在对 Cloud Firestore 进行以下查询:
` var meeting = await db.collection("meetings").where(
"pin", "==", request.body.Digits).where(
"status", "==", "in-progress").get()`
这适用于我们的本地机器,但在我们部署到 EC2 时会失败。我们在两者上都安装了 Firestore 客户端库,但我们在部署时对其进行了 webpack。
这个错误特别令人费解,因为上面的 sn-p 被包裹在了一个 try 块中,但是在没有被捕获的情况下,在该行上抛出了以下错误:
UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'node_modules/protobufjs/google/protobuf/api.proto'
at Object.openSync (fs.js:431:3)
at Object.readFileSync (fs.js:333:35)
at fetch (/home/node/server/app.compiled.js:350251:34)
at Root.load (/home/node/server/app.compiled.js:350285:13)
at Root.loadSync (/home/node/server/app.compiled.js:350326:17)
at Object.loadSync (/home/node/server/app.compiled.js:347406:17)
at Object../node_modules/@grpc/proto-loader/build/src/index.js (/home/node/server/app.compiled.js:65075:37)
at __webpack_require__ (/home/node/server/app.compiled.js:20:30)
at Object.<anonymous> (/home/node/server/app.compiled.js:222521:25)
at Object../node_modules/google-gax/build/src/grpc.js (/home/node/server/app.compiled.js:222775:30)
at __webpack_require__ (/home/node/server/app.compiled.js:20:30)
at Object../node_modules/google-gax/build/src/index.js (/home/node/server/app.compiled.js:222819:16)
at __webpack_require__ (/home/node/server/app.compiled.js:20:30)
at Object.<anonymous> (/home/node/server/app.compiled.js:44631:13)
at Object../node_modules/@google-cloud/firestore/build/src/v1/firestore_client.js (/home/node/server/app.compiled.js:45987:30)
at __webpack_require__ (/home/node/server/app.compiled.js:20:30)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
在不实际更改查询的情况下,我们已经尝试了几乎所有您能想到的方法——重新执行 package.json 和我们的构建脚本,但无法弄清楚这一点。有什么帮助吗?
【问题讨论】:
-
您尝试安装缺少的依赖项吗?
-
是的,我们尝试单独安装 protobuf,即使它应该与 Firebase 一起安装,它仍然无法正常工作。
-
你搞定了吗?我也有类似的情况。
-
没有。解决方法是我们将所有 firebase 调用移至后端。耗时但值得,因为从浏览器调用 firebase 无论如何都是不好的风格。
标签: node.js firebase amazon-ec2 google-cloud-firestore