nodejs-firestore icon indicating copy to clipboard operation
nodejs-firestore copied to clipboard

When no credentials are available, firestore call never returns.

Open SurferJeffAtGoogle opened this issue 3 years ago • 7 comments

I expect it to return an error code, but instead the call never returns. Here's the code.

import admin from 'firebase-admin';

    admin.initializeApp({
      credential: admin.credential.applicationDefault(),
    });

    await db.collection('hello').doc('world').get(),

SurferJeffAtGoogle avatar Feb 08 '21 23:02 SurferJeffAtGoogle

Hey @SurferJeffAtGoogle

Thanks for the report. I tried to reproduce with below snippet but failed.


import admin from 'firebase-admin';

const app = admin.initializeApp({
  credential: admin.credential.applicationDefault(),
});

async function test() {
  const db = app.firestore();
	const snap = await db.collection('hello').doc('world').get();
	console.log(`${snap.data()}`);
}

test();

Can you provide a bit more info to reproduce this?

wu-hui avatar Feb 16 '21 13:02 wu-hui

@wu-hui how did it fail? It wasn't top-level await missing was it? I would expect test() to be awaited?

crwilcox avatar Feb 16 '21 21:02 crwilcox

It failed to reproduce the hang. test() runs and returns, with undefined printed to the console.

@SurferJeffAtGoogle mentioned in our chat that this happens in a test in Github Actions, so this might be something else. I have not tried yet.

wu-hui avatar Feb 16 '21 23:02 wu-hui

@SurferJeffAtGoogle Is this issue resolved? I tried with GA, and it looks like it is working fine, with my snippet.

If you still have issues, can you try to run it outside of GA, and can you share the full snippet with me?

Thanks

wu-hui avatar Mar 09 '21 18:03 wu-hui

I have a work-around. It may be the environment the github action runs in. What does the client do if the server accepts the connection but never sends bytes on the socket?

SurferJeffAtGoogle avatar Mar 10 '21 20:03 SurferJeffAtGoogle

To reproduce, try instantiating the client in a docker container with the network turned off.

SurferJeffAtGoogle avatar Mar 11 '21 03:03 SurferJeffAtGoogle

With the script:

const admin = require('firebase-admin');

const app = admin.initializeApp({
  credential: admin.credential.applicationDefault(),
});
async function test() {
  const db = app.firestore();
  const snap = await db.collection('hello').doc('world').get();
  console.log(`${snap.data()}`);
}
test();

With Wifi on it immediately prints undefined. With Wifi off it hangs for a while and then throws the error Error: 14 UNAVAILABLE: Name resolution failed for target dns:firestore.googleapis.com:443 after 41 seconds for me.

danieljbruce avatar May 30 '22 18:05 danieljbruce