firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.83k stars 889 forks source link

Firebase SignUp with Email/Password is very slow in the first times #7830

Open KpYeahStar opened 10 months ago

KpYeahStar commented 10 months ago

Operating System

Linux

Browser Version

Google Chrome Version 119.0.6045.159 (Official Build) (64-bit)

Firebase SDK Version

10.6.0

Firebase SDK Product:

Auth

Describe your project's tooling

Firebase Authentication by SignUp with Email and Password

Describe the problem

In the first times, Firebase Authentication with Email/Password takes more 8 seconds to complete request.

Screenshot from 2023-12-02 14-02-37

If I retry the second times, it's very fast, takes less than 1 second.

Problem, I use Blocking Cloud Function (beforeUserCreated) combine with Firebase Authentication, the API identitytoolkit (account:signup) returns Error Message "BLOCKING_FUNCTION_ERROR_RESPONSE : Cloud function deadline exceeded.", cause timeout 7 seconds as Blocking Function's document descriptioned, therefore do Sign Up in first times always return Error, (it's OK when do signup in the second times)

image

Please help me to resolve this issue.

Steps and code to reproduce issue

Client Signup and Link Credential Code

const credential = EmailAuthProvider.credential(this.email, password);
await linkWithCredential(prevUser, credential);`

Blocking Cloud Function Code


export const beforeCustomerCreated = beforeUserCreated((event) => {
  return {
    customClaims: {
      role: AppRole.Customer,
    },
  };
});
butri71 commented 10 months ago

I'm using Firebase v9 and facing failure signing-in and I suspect it is due to delays since yesterday. Again, this code has been working fine for over years and all of sudden I can't authenticate users.

I believe my issue is related to yours however I'm going to open a new issue!

NhienLam commented 10 months ago

Hi @KpYeahStar, this might be a cold start issue: https://firebase.google.com/docs/functions/tips#min.

You can try invoking the function after deploying it to reduce the latency at login.

KpYeahStar commented 10 months ago

Hi @KpYeahStar, this might be a cold start issue: https://firebase.google.com/docs/functions/tips#min.

You can try invoking the function after deploying it to reduce the latency at login.

Hi, please re-check my issue description. I call direct to google API (identity toolkit) from client by SDK js, not by Cloud Function.