[英]FirebaseError: The datastore operation timed out
I have firestore collection with 50000 document when I'm trying to get all documents using below code I'm getting error当我尝试使用以下代码获取所有文档时,我有 50000 个文档的 firestore 集合我收到错误
const { db } = require("./firebase");
getdata()
function getdata() {
console.log("entered");
db.collection("mycollection")
.where("id", "!=", null)
.get()
.then((querySnapshot) => {
console.log("got res");
for (let i in querySnapshot.docs) {
console.log(doc.id, " => ", doc.data());
}
});
}
while executing this I'm getting this error执行此操作时出现此错误
D:\project\project_duplicate>node index.js
entered
(node:17848) UnhandledPromiseRejectionWarning: FirebaseError: The datastore operation timed out, or the data was temporarily unavailable.
at new FirestoreError (D:\project\project_duplicate\node_modules\@firebase\firestore\dist\index.node.cjs.js:266:28)
at fromRpcStatus (D:\project\project_duplicate\node_modules\@firebase\firestore\dist\index.node.cjs.js:4522:12)
at fromWatchChange (D:\project\project_duplicate\node_modules\@firebase\firestore\dist\index.node.cjs.js:4767:35)
at PersistentListenStream.onMessage (D:\project\project_duplicate\node_modules\@firebase\firestore\dist\index.node.cjs.js:12995:27)
at D:\project\project_duplicate\node_modules\@firebase\firestore\dist\index.node.cjs.js:12928:30
at D:\project\project_duplicate\node_modules\@firebase\firestore\dist\index.node.cjs.js:12964:28
at D:\project\project_duplicate\node_modules\@firebase\firestore\dist\index.node.cjs.js:14554:20
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:17848) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:17848) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[2020-12-03T19:23:10.734Z] @firebase/firestore: Firestore (8.1.1): Connection GRPC stream error. Code: 1 Message: 1 CANCELLED: Disconnecting idle stream. Timed out waiting for new targets.
The error seems cause by ran out of memory:该错误似乎是由 memory 用完引起的:
The datastore operation timed out, or the data was temporarily unavailable.
数据存储操作超时,或数据暂时不可用。
Similar to this case because you have getting and returning a large collection.与这种 情况类似,因为您获取并返回了一个大型集合。 You should apply a limit or batch or pagination query in order to avoid running out of memory and excessive costs.
您应该应用限制或批处理或分页查询,以避免用完 memory 和过多的成本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.