firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

WSL 2 auth.getUser() sometimes takes a long time

Open SiarheiBokuts opened this issue 4 years ago • 3 comments

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

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

SiarheiBokuts avatar Sep 10 '21 13:09 SiarheiBokuts

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 avatar Sep 10 '21 20:09 hiranya911

@hiranya911 thanks. i debugged this method and found that sometimes I have a timeout (after 25 sec). do u have any ideas why?

SiarheiBokuts avatar Sep 13 '21 10:09 SiarheiBokuts

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.

hiranya911 avatar Sep 13 '21 17:09 hiranya911

Closing due to inactivity

lahirumaramba avatar Jan 17 '23 20:01 lahirumaramba