New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Firestore] hangs indefinitely #1162
Comments
I found a few problems with this issue:
|
@google-oss-bot I deleted the first step thinking it was unnecessary |
Firestore uses |
Yeah I meant |
|
I'm having a similar issue. When I follow the instructions found here: https://firebase.google.com/docs/admin/setup I get the same I have created a service account and have the resulting json file available to my node project. This is a very, very simple node app that just tries to auth and get a document from firestore. It uses...
I am just performing a simple get on a document that exists in a collection that exists (very similar to the code above). I have used firestore successfully in the past with node without issue. NOTE: In the code below I preset the GOOGLE_APPLICATION_CREDENTIALS to the serviceAccount JSON. I have also tried to import the file and pass it to the creds function. Both have the same issue. import admin from 'firebase-admin';
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: 'https://project-name.firebaseio.com', // project-name subbed for my specific project
});
const db = admin.firestore();
export const getDoc = async (): Promise<void> => {
try {
const dbRef = db.collection('collection'); // collection subbed for my existing collection
const result = await dbRef.doc('doc-id').get(); // doc-id subbed for an existing doc-id
console.log(result);
} catch (err) {
console.error("error connecting", err);
}
}; |
@schmidt-sebastian interestingly this problem doesn't exist on a Vultr server I created for the purpose 🧐 Perhaps this is because I use a proxy in my development? |
@ryanccn perhaps this is mac related? I am on I dropped the Firebase Admin SDK back to 7.x and got the following error:
Could be a red herring, but thought it was worth mentioning. |
Hmm. |
Note that you can turn on additional logging by setting the following environment variables:
This should show extensive logging output and might point us to the root cause. |
Thanks for the tip @schmidt-sebastian. Here are the subsequent logs and errors which look very similar to those I received when I dropped back to 7.x of the SDK... I can paste the full logs but here are the relevant repeating parts. Appears the issue is that
|
Upon further reading of the above issue. I think I am the victim of corporate malware. This is a work MacBook and subsequently has Netskope and god knows what else monitoring and messing with SSL traffic. I added Are there other ways to authenticate the firebase admin client if there are no workarounds available? As it seems the issue here is some software between my app and the internet is tampering with the cert. |
These debug messages, uh, seem to just say "No connection established" because of a timeout? |
For one thing, I'm on a personal MacBook Pro so my problem can't be because of corporate malware. |
I am also experiencing the same issue, any requests to firebase through proxy, hand indefinitely then timeout after 60000ms |
Just in case it's useful to anyone that comes across this issue, I also had the problem with the connection timing out. After turning on additional logging, as recommended by @schmidt-sebastian, I saw firebase-admin was trying to connect to the host set in the |
Looks like lots of people are having this problem but with different reasons 😅 |
@zoheiry If you are experiencing connection problems with the Web SDK (in a browser), take a look here: firebase/firebase-js-sdk#1674 I am pointing at this because the 60s timeout+Proxy problem used to be very common on our other platforms. It is not applicable to the firebase-admin-node SDK however. |
After switching to using Shadowsocks there's now a different error: {
"code":"ERR_INVALID_PROTOCOL",
"details":"Getting metadata from plugin failed with error: Protocol \"https:\" not supported. Expected \"http:\"",
"metadata":{"internalRepr":{},"options":{}}
} Here's the snippet in my export https_proxy=http://127.0.0.1:7890
export http_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7890 |
I had the same issue. docRef.set() and .get() methods timing out and getting error 14 messages. Firebase emulator was setup with: Using extra logs - thank you @schmidt-sebastian!
I saw that admin sdk was trying to access port 8000 without emulators running. Removing it in CLI resolved it. Thanks @lnoir Setting Maybe having .useEmulator() in the admin sdk would be a better dev experience: export const db =
process.env.NODE_ENV === 'production' ? admin.firestore() : admin.firestore().useEmulator(port); At the same time everything is working as it is intended as far as I can tell. |
Personally I'm not a fan of having to add an environment check to application code. I think what might be useful is if the Firestore client just logged a message out whenever it's connecting to the local emulator. That way there's a clear feedback of what's going on, in case somebody forgot to clear their env variables. |
I have identified the issue causing this, and its been introduced in the past year or so, I do not know at what point. But basically what's happening is it seems admin is spinning up a background task, and runs with that context. When your app shutsdown, that background task can sometimes hang around, so on the next time initializeApp is called it appears to work fine but any method calls will just hang forever. I have played around with app().delete() which does fix the problem but then you get even more strange behavior. Because even though app().delete() was called by the previous instance on app shutdown, and an entirely new instance is spun up and a new initializeApp() is called, the new instance will sometimes throw an exception saying "The ["DEFAULT"] app has been deleted.". I think the only way to handle this is to create instances of the app with a unique id each time, and then dispose of those that way you don't encounter this race condition on the DEFAULT app. |
@ryanccn hello, do you fixed this problem? I also used proxy,I'm in china. |
No... I've stopped using Firebase. But I would certainly like to see this problem solved 😇 |
Yes looks like it is some issue with corporate vpn or any other software companies have installed. Worked on personal laptop |
Using TUN can solve the problem. |
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
Doing anything with Firestore hangs indefinitely. After testing with
resolution
s of@grpc/grpc-js
,{"error":{}}
Relevant Code:
http://github.com/leerob/nextjs-vercel-firebase
(This is a Next.js API route)
The text was updated successfully, but these errors were encountered: