最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - No connection established Error in firebase firestore & grpc - Stack Overflow

programmeradmin1浏览0评论

It is a function to add new data if it does not exist by referring to existing data and update data if it exists. It works well, but after an hour gRpc error occurs. Details below:

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: {} } }
And here is my code

<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>

Is there a problem with my source code? How can i fix it..?

It is a function to add new data if it does not exist by referring to existing data and update data if it exists. It works well, but after an hour gRpc error occurs. Details below:

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: {} } }
And here is my code

<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>

Is there a problem with my source code? How can i fix it..?

Share Improve this question edited Oct 25, 2019 at 4:33 Anna 3,2963 gold badges17 silver badges31 bronze badges asked Oct 25, 2019 at 2:39 cho shcho sh 331 silver badge4 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

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:

Workaround

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

OR

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.


At the end, your dependency should read:

@grpc/grpc-js": "0.6.9"

This conversation thread grpc/grpc-node#1027 also explain ways to update your deps and can also be of great help.

发布评论

评论列表(0)

  1. 暂无评论