javascript - firebase firestore 和 grpc 中未建立连接错误

标签 javascript firebase google-cloud-firestore

它是一个函数,如果不存在则通过引用现有数据来添加新数据,如果存在则更新数据。它运行良好,但一个小时后gRpc发生错误。详情如下:

Error: No connection established at Http2CallStream.<anonymous> (D:\zyleTcpServer\node_modules\@grpc\grpc-js\build\src\call.js:68:41) at Http2CallStream.emit (events.js:215:7) at D:\zyleTcpServer\node_modules\@grpc\grpc-js\build\src\call-stream.js:75:22 at processTicksAndRejections (internal/process/task_queues.js:75:11) --------------------------------------------- at BunWrapper.Readable.on (D:\zyleTcpServer\node_modules\bun\node_modules\readable-stream\lib\_stream_readable.js:729:33) at D:\zyleTcpServer\node_modules\@google-cloud\firestore\build\src\index.js:920:26 at new Promise (<anonymous>) at Firestore._initializeStream (D:\zyleTcpServer\node_modules\@google-cloud\firestore\build\src\index.js:881:16) at D:\zyleTcpServer\node_modules\@google-cloud\firestore\build\src\index.js:1017:28 { code: 14, details: 'No connection established', metadata: Metadata { internalRepr: Map {}, options: {} } }
这是我的代码

<code>
    const docName = `${vin}-${dtc}`; //make doc
    const ebsRef = db.collection('events').doc(docName);
    await db.runTransaction((t) => t.get(ebsRef)
      .then(async (doc) => {
        if (!doc.exists) {
          return t.set({
           startDatetime: firebase.firestore.FieldValue.serverTimestamp(),
           endDatetime: firebase.firestore.FieldValue.serverTimestamp(),
           description: dtcData.description,
           dtcCode: dtc,
           eventType: brokenType,
           scannerCode: dtcData.scanner,
           vin,
          });
       }
       return t.update(ebsRef, {
         status: (rawDtc.status === '08' ? 2 : 1),
         endDatetime: firebase.firestore.FieldValue.serverTimestamp(),
      });
    </code>
    <br>

我的源代码有问题吗? 我该如何解决...?

最佳答案

Other people reported to be having the same issue in the past week, as mentioned on Firebase Functions Github. This occurs to every kind of function that involves firestore and it's related to firestore changing grpc to grpc-js. As mentioned in the conversation thread, there are some workarounds that you can try:

解决方法

1 - Updating from "firebase-functions": "^3.2.0" to "firebase-functions": "^3.3.0"

2 - Deleting your /src/functions/node_modules and /src/functions/package-lock.json, updating your dependencies, and pushing your changes that include your new dependencies in your /src/functions/package.json to your firebase app.


最后,你的依赖应该是:

@grpc/grpc-js": "0.6.9"

这个对话线程 grpc/grpc-node#1027还解释了更新您的部门的方法,这也很有帮助。

关于javascript - firebase firestore 和 grpc 中未建立连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58551487/

相关文章:

javascript - 任何基于 JavaScript/jQuery 的 html 数据处理器/美化器?

javascript - Reactjs 中 CSS className 的类与样式

firebase - 在 Firebase 中执行扇出数据的事务

firebase - 如果文档不存在,则 Flutter Firebase

javascript - Firestore 安全规则 - 如何检查 FieldValue.increment 是否有效?

firebase - 没有创建 Firebase App '[DEFAULT]' - 在 Flutter 和 Firebase 中调用 Firebase.initializeApp()

javascript - 不允许加载本地资源 : file:///var/mobile/Containers/Data/Application/03F63826-7849-47C3-A6DF-E1EB1113FF0A/Documents/xxx. png

javascript - Angular 数据表 : Unknown provider

android - 如何修复错误 :Could not find com. google.gms : google-services: 3. 0.0.?

android - 模拟器上未收到 Firebase 消息