firebase-admin-node
firebase-admin-node copied to clipboard
WSL 2 auth.getUser() sometimes takes a long time
Environment
- Operating System version: Windows 10 pro 21h1
- Firebase SDK version: "firebase-admin": "^9.11.1",
- Firebase Product: auth
- Node.js version: v12.22.3
- NPM version: 6.14.13
Problem
Hi, I have the win10 pro 21h1 version with WSL2. my system is ubuntu 20.04.
I found the issue with the firebase admin getUser(uid) method. For some reason sometimes (once in 30 times) it took really long time ~ 1min;
See image below :

this getUser method is just a call of getUser from firebase auth
export class FirebaseService {
public static auth: admin.auth.Auth;
constructor() {}
static async init() {
const serviceAccount = SECRETS['firebase-sdk'];
admin.initializeApp({
credential: admin.credential.cert(serviceAccount as admin.ServiceAccount)
});
this.auth = admin.auth();
console.log('FirebaseService has been initialized successfully');
}
static async verifyToken(token): Promise<admin.auth.DecodedIdToken> {
return await this.auth.verifyIdToken(token);
}
static async getUser(uid): Promise<admin.auth.UserRecord> {
return this.auth.getUser(uid);
}
}
Maybe u have some ideas or maybe u know the reason why it works like this. Because all other queries work fine. Thanks
May be some of your requests are timing out? There's a 25 second timeout on Auth requests, and the SDK would retry timed out requests too.
https://github.com/firebase/firebase-admin-node/blob/bb1fb6f6341786777264c26472aa630b158a5dae/src/auth/auth-api-request.ts#L63-L64
That explains how some requests can take up to 78 seconds, but I can't say why those requests timed out. If it happens frequently, may be you should try the Auth REST API directly and see if there's some networking issue at play.
@hiranya911 thanks. i debugged this method and found that sometimes I have a timeout (after 25 sec). do u have any ideas why?
Can't give a specific reason other than it's a network issue. Like I said, try calling the REST API directly and see if you can isolate the issue that way.
Closing due to inactivity