【问题标题】:FirebaseError: An internal error occurredFirebaseError:发生内部错误
【发布时间】:2018-12-12 09:46:33
【问题描述】:

我正在实施使用 firestore 的 kiosk 项目。

自助服务终端运行时间很长(超过 48 小时)。

但是,有时我的 Firestore onSnapShot 侦听器会通过以下消息出错。

[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);
}

【问题讨论】:

    标签: javascript reactjs firebase google-cloud-firestore


    【解决方案1】:

    firestore 会话中存在一些内部问题。

    我确实在“onSnapshot”上添加了错误处理功能。

    如果错误发生在“onSnapshot”上,它会重新连接所有这些监听器。

    到目前为止(~3周),使用firestore数据库没有问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-31
      • 2017-06-24
      • 2018-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-04
      • 2021-04-09
      相关资源
      最近更新 更多