[英]FirebaseError: The datastore operation timed out
當我嘗試使用以下代碼獲取所有文檔時,我有 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.
該錯誤似乎是由 memory 用完引起的:
數據存儲操作超時,或數據暫時不可用。
與這種 情況類似,因為您獲取並返回了一個大型集合。 您應該應用限制或批處理或分頁查詢,以避免用完 memory 和過多的成本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.