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

cho*_* sh 3 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>
Run Code Online (Sandbox Code Playgroud)

我的源代码有问题吗?我该如何修复它..?

sll*_*pis 5

正如Firebase Functions Github上提到的那样,其他人报告说在过去一周中遇到了同样的问题这发生在涉及 firestore 的各种函数中,并且与 firestore 更改. 正如对话线程中提到的,您可以尝试一些解决方法:grpcgrpc-js

解决方法

1 - 从“firebase-functions”:“^3.2.0”更新到“firebase-functions”:“^3.3.0”

或者

2 - 删除您的/src/functions/node_modules/src/functions/package-lock.json,更新您的依赖项,并将您的更改(包括您的新依赖项)推/src/functions/package.json送到您的 Firebase 应用程序。


最后,您的依赖项应为:

@grpc/grpc-js": "0.6.9"

这个对话线程grpc/grpc-node#1027也解释了更新你的 deps 的方法,也可以提供很大的帮助。