Error: internal at new HttpsErrorImpl when invoking Firebase https callable cloud functions

Viewed 1296

This is the error I get whenever I call manageSubscription() which invokes the https callable cloud function:

core.js:4081 ERROR Error: internal
    at new HttpsErrorImpl (index.cjs.js:60)
    at _errorForResponse (index.cjs.js:155)
    at Service.<anonymous> (index.cjs.js:560)
    at step (tslib.es6.js:100)
    at Object.next (tslib.es6.js:81)
    at fulfilled (tslib.es6.js:71)
    at ZoneDelegate.invoke (zone-evergreen.js:364)
    at Object.onInvoke (core.js:27149)
    at ZoneDelegate.invoke (zone-evergreen.js:363)
    at Zone.run (zone-evergreen.js:123)

Using:

"@angular/core": "^10.0.4",
"@angular/fire": "^6.0.3",

Here is my Apps Module:

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    AngularFireModule.initializeApp(environment.firebaseConfig),
    AngularFireFunctionsModule,
    SharedComponentsModule,
    AppRoutingModule
  ],
  providers: [
    { provide: ORIGIN, useValue: 'http://localhost:5001' }
  ],
  bootstrap: [AppComponent]
})

I am invoking https callable cloud function in my Service:

Added dependency:

constructor(private firebaseFunctions: AngularFireFunctions) {}

This is the method:

public manageSubscription(){
  this.firebaseFunctions.useFunctionsEmulator('http://localhost:5001');

  const functionRef = this.firebaseFunctions.httpsCallable('testFunction');
  functionRef({ returnUrl: 'window.location.origin' })
    .subscribe(response => {
      console.log(response);
  });
}

This is the cloud function:

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';

admin.initializeApp();

exports.testFunction = functions.https.onCall((data, context) => {
    console.log('reached');
  return { date: true };
});

I can't see the calls made to this function in the cloud function logs or in the chrome dev console Network tab. What am I doing wrong?

I tried both cloud functions emulator and live app. Still no luck!

I have been trying to debug this since the past 3 days and have lost a bit of hair and weight :/

1 Answers

You're not the only one who lost hair because of this issue. I solved by simply updating the firebase package in the client (I did the same thing on Friday but it wasn't solved yet) The version 7.22.0 was coded by the devil, upgrade it to 7.22.1 and you'll hopefully be fine.

Related