6

I'm using firebase auth in my application and am implementing other providers, in this case microsoft. Email/password works fine (app is initialised etc.) but trying signInWithPopup, as shown below:

import * as firebaseAuth from 'firebase/auth';

export function signupWithMicrosoft(): Promise<firebaseAuth.UserCredential> {
  const auth = firebaseAuth.getAuth();
  const provider = new firebaseAuth.OAuthProvider('microsoft.com');
  return firebaseAuth.signInWithPopup(auth, provider).catch(Promise.reject);
}

fails inconsistently with:

Uncaught (in promise) Error: INTERNAL ASSERTION FAILED: Pending promise was never set
    debugFail assert.ts:256
    debugAssert assert.ts:271
    reject abstract_popup_redirect_operation.ts:135
    onAuthEvent abstract_popup_redirect_operation.ts:104
    sendToConsumer auth_event_manager.ts:97
    onEvent auth_event_manager.ts:68
    onEvent auth_event_manager.ts:65
    initAndGetManager popup_redirect.ts:133

The error appears sometimes and not others, but is definitely there more than not. I have triple checked redirect URIs in Azure (originally I was getting a trailing slashes error). One thing I have not attempted is redirect login as opposed to popup login.

Attempts at watching what happens inside firebase have led me to believe it's some sort of initialisation problem, with an AuthEventConsumer not having the promise it resolves upon consuming the event being set, however I'm stuck trying to find how to initialise that properly. The actual authentication requests go through and succeed, but once it tries to resolve that promise (that doesn't exist) it complains.

Ecotiny
  • 91
  • 1
  • 5

1 Answers1

2

EDIT: It ended up requiring me to switch to redirect rather than popup.

It turns out that this was a consequence of the auth/popup-closed-by-user thing that goes on in Firefox, just poorly logged by me. The fix was to call the function directly (synchronously from a user input), not from an async function. Apologies as these factors were not clearly laid out in the question.

Ecotiny
  • 91
  • 1
  • 5