我正在实施使用Firestore的信息亭项目。
信息亭运行时间非常长(超过48小时)。
但是,有时我的onSnapShot监听器上的firestore用以下消息使错误。
[Error message]
FirebaseError: An internal error occurred.
at new FirestoreError(C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\@firebase\firestore\dist\index.node.cjs.js:348:28)
at JsonProtoSerializer.fromRpcStatus(C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\@firebase\firestore\dist\index.node.cjs.js:4919:16)
at JsonProtoSerializer.fromWatchChange(C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\@firebase\firestore\dist\index.node.cjs.js:5417:44)
at PersistentListenStream.onMessage(C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\@firebase\firestore\dist\index.node.cjs.js:13092:43)
at ? (C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\@firebase\firestore\dist\index.node.cjs.js:13037:34)
at PersistentListenStream.<anonymous>(C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\@firebase\firestore\dist\index.node.cjs.js:13013:47)
at step(C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\tslib\tslib.js:133:27)
at Object.next(C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\tslib\tslib.js:114:57)
at ? (C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\tslib\tslib.js:107:75)
at Promise(<anonymous>)
at Object.__awaiter(C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\tslib\tslib.js:103:16)
at ? (C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\@firebase\firestore\dist\index.node.cjs.js:13009:62)
at ? (C:\release_pickUp_1210_v15\win-unpacked\resources\app.asar\node_modules\@firebase\firestore\dist\index.node.cjs.js:12485:20)
at ? (<anonymous>)
这是我的代码。
componentDidMount() {
port.open(console.log('port is opend'));
if (TEST) {
port.onRead(this.readFromPCBtest);
} else {
port.onRead(this.readFromPCB);
}
this.unsubscribe = db.onceGetVM().onSnapshot(this.onErrorUpdate);
this.unsubscribeForOrders = db.onceGetOrders().onSnapshot(this.onOrdersUpdate);
this.unsubscribeForCleanings = db.onceGetCleanings().onSnapshot(this.onCleaningsUpdate);
for (let i = 0; i < cleaningList.length; i++) {
unsubscribeForLatestOrders.push(db.onceGetLatestOrders(i).onSnapshot(this.onLatestOrdersUpdate));
unsubscribeForLatestCleanings.push(db.onceGetLatestCleanings(i + 1).onSnapshot(this.onLatestCleaningsUpdate));
}
this.timer = setInterval(this.doClean, TIME_INTERVAL);
}
componentWillUnmount() {
port.close(console.log('port is closed'));
this.unsubscribe();
this.unsubscribeForOrders();
this.unsubscribeForCleanings();
this.unsubscribeForLatestOrders();
for (let i = 0; i < cleaningList.length; i++) {
unsubscribeForLatestOrders[i]();
unsubscribeForLatestCleanings[i]();
}
clearInterval(this.timer);
}
答案 0 :(得分:0)
firestore会话中存在一些内部问题。
我确实在“ onSnapshot”上添加了错误处理功能。
如果错误发生在“ onSnapshot”上,它将重新连接所有这些侦听器。
直到现在(约3周),使用firestore数据库都没有问题。