firebase-functions icon indicating copy to clipboard operation
firebase-functions copied to clipboard

Firestore/triggers grpc-js No connection established errors

Open clytras opened this issue 7 years ago • 53 comments

Related issues

https://github.com/googleapis/nodejs-firestore/issues/768

https://github.com/firebase/firebase-js-sdk/issues/1783

https://github.com/grpc/grpc-node/issues/1027

Version info

node: 10.15.1

firebase-functions: 3.3.0

firebase-tools: 7.6.0

firebase-admin: 8.6.0

Test case

exports.addDriverLocation = functions.region(region).firestore
  .document('drivers/{userId}/locations/{locationId}')
  .onCreate((snap, context) => {
    const { userId = -3 } = context.params;
    const record = snap.data();
    const { location = {}} = record;
    const {
      uuid,
      coords: {
        latitude,
        longitude
      } = {},
      extras
    } = location;

    return snap.ref.set({
      userId,
      // server timestamp
      sts: admin.firestore.Timestamp.fromDate(new Date()),
      // client timestamp
      cts: admin.firestore.Timestamp.fromDate(new Date(timestamp)),
      latitude,
      longitude,
      extras
    });

Steps to reproduce

  1. Create a firestore trigger function

Expected behavior

Every call should be get executed without gRPC related errors.

Actual behavior

Every now and then we get a No connection established error:

Error: No connection established
    at Http2CallStream.call.on (/srv/functions/node_modules/@grpc/grpc-js/build/src/client.js:96:45)
    at Http2CallStream.emit (events.js:194:15)
    at Http2CallStream.EventEmitter.emit (domain.js:459:23)
    at process.nextTick (/srv/functions/node_modules/@grpc/grpc-js/build/src/call-stream.js:75:22)
    at process._tickCallback (internal/process/next_tick.js:61:11)

It encountered 8600 exact errors for the past week:

Cloud Functions erors view

For every other firestore operation, we used old grpc as described here https://github.com/googleapis/nodejs-firestore/issues/768#issuecomment-537311719:

const Firestore = require('@google-cloud/firestore');
const grpc = require('grpc');
const firestore = new Firestore({ grpc });

but we don't know how to set old grpc for functions.region(region).firestore to get rid of all these errors.

We are not sure if here is the right place to post this issue or the https://github.com/googleapis/nodejs-firestore. If this is the case, the please close this issue and we'll go and report it on the nodejs-firestore repo.

Were you able to successfully deploy your functions?

No errors during functions deploy.

clytras avatar Oct 16 '19 13:10 clytras

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Oct 16 '19 13:10 google-oss-bot

I'm also having this issue – just from today.

shankie-codes avatar Oct 17 '19 16:10 shankie-codes

I've been having the same issues as well

LureOfAdventure avatar Oct 17 '19 23:10 LureOfAdventure

Issue here as well when deploying a scheduled function. Works for about an hour then crashes. There are other threads going on but fail to address the firebase scheduled function side of things.

mrmodelo avatar Oct 18 '19 03:10 mrmodelo

I've also been getting this error intermittently yesterday and today on a range of https.onCall functions

tantzygames avatar Oct 18 '19 06:10 tantzygames

Getting also many occurencies of this error last few days with firestore triggers.

trigger: firestore create trigger. runtime: Node.js 8 Last deployed: 16 October 2019 at 13:55:30 UTC+3 Region: europe-west1

firebase packages: "firebase": "^7.1.0", "firebase-admin": "8.6.0", "firebase-functions": "^3.2.0", "firebase-tools": "^7.5.0",

diginikkari avatar Oct 18 '19 08:10 diginikkari

@mrmodelo this occurs to every kind of function that involves firestore and it's related to firestore changing grpc to grpc-js. There is a workaround for other kind of functions as you can see on my initial post, but I can't find a way to set old grpc for firestrore funtion triggers.

clytras avatar Oct 18 '19 09:10 clytras

Seeing the same error on Firestore delete triggers. I just started noticing this issue this morning.

"firebase-admin": "^8.0.0",
"firebase-functions": "^3.1.0",

Region: North America / east-coast EST

adamkpurdy avatar Oct 18 '19 14:10 adamkpurdy

Same issue here, started to get No connection established error week ago

nourziady avatar Oct 18 '19 15:10 nourziady

This looks resolved. My triggers are firing again. Can anyone else confirm?

adamkpurdy avatar Oct 18 '19 18:10 adamkpurdy

@adamkpurdy It seems to be sporadically failing on our project still.

jhk115 avatar Oct 18 '19 18:10 jhk115

Since first seeing the problem, it will usually pass once after deployment, and then fail consistently after

mrmodelo avatar Oct 18 '19 18:10 mrmodelo

@adamkpurdy since last functions deploy, I can't see any errors, but for me it's too early to tell. I'll leave this open for some days and if there won't be any more related errors I'll close this.

clytras avatar Oct 18 '19 18:10 clytras

I'm seeing the error again.

adamkpurdy avatar Oct 18 '19 18:10 adamkpurdy

I am still experiencing this issue as well.

LureOfAdventure avatar Oct 18 '19 18:10 LureOfAdventure

Trying to narrow down our issue - are you guys doing anything with storage inside these functions?

jhk115 avatar Oct 18 '19 18:10 jhk115

I was experiencing this since yesterday morning. I found this thread about 30 minutes ago, figured since grpc was mentioned I'd reinstall. I blew away node_modules, package-lock.json, then reinstalled and redeployed. Everything is back to normal so far. I haven't checked what is any package changed yet, so fingers crossed.

glawson avatar Oct 18 '19 18:10 glawson

@jhk115 I'm not doing anything with storage. Only Firestore.

LureOfAdventure avatar Oct 18 '19 18:10 LureOfAdventure

@jhk115 only Firestore

adamkpurdy avatar Oct 18 '19 18:10 adamkpurdy

@jhk115 This is because of a dependency that firestore is using called grpc-js as mentioned by @clytras

@mrmodelo this occurs to every kind of function that involves firestore and it's related to firestore changing grpc to grpc-js. There is a workaround for other kind of functions as you can see on my initial post, but I can't find a way to set old grpc for firestrore funtion triggers.

There have been workarounds referenced if you look further back in the thread and to the linked issues on the original comment, however there are still situations where you can not manage this dependency (to our knowledge so far)

mrmodelo avatar Oct 18 '19 18:10 mrmodelo