【发布时间】:2020-12-03 19:38:02
【问题描述】:
当我尝试使用以下代码获取所有文档时,我有 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());
}
});
}
执行此操作时出现此错误
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.
【问题讨论】:
-
Firebase 实时数据库和 Cloud Firestore 是两个独立的数据库。请仅使用相关标签标记您的问题,不要同时使用两者。
标签: javascript node.js firebase google-cloud-firestore