'AngularFire Functions: Service functions is not available

AppModule:

import { getApp, initializeApp, provideFirebaseApp } from "@angular/fire/app";
import { getFunctions, provideFunctions } from "@angular/fire/functions";

@NgModule({
  imports: [
    ...
    provideFirebaseApp(() => initializeApp(environment.firebase)),
    provideFunctions(() => getFunctions(getApp())),
  ],
  bootstrap: [AppComponent]
})

A component within a child module of AppModule:

import { Functions } from "@angular/fire/functions";

constructor(
    private functions: Functions,
  ) {}

Whenever this component initialized, my app crashes and I get the following error in the console:

core.mjs:6485 ERROR Error: Uncaught (in promise): Error: Service functions is not available
Error: Service functions is not available
    at Provider.getImmediate (index.esm2017.js:147:23)
    at getFunctions (index.esm2017.js:651:49)
    at angular-fire.js:227:48
    at angular-fire.js:160:59
    at _ZoneDelegate.invoke (zone.js:372:26)
    at Zone.run (zone.js:134:43)
    at NgZone.runOutsideAngular (core.mjs:25447:28)
    at runOutsideAngular (angular-fire.js:160:35)
    at angular-fire.js:227:21
    at app.module.ts:92:28
    at resolvePromise (zone.js:1211:31)
    at resolvePromise (zone.js:1165:17)
    at zone.js:1278:17
    at _ZoneDelegate.invokeTask (zone.js:406:31)
    at Object.onInvokeTask (core.mjs:25535:33)
    at _ZoneDelegate.invokeTask (zone.js:405:60)
    at Zone.runTask (zone.js:178:47)
    at drainMicroTaskQueue (zone.js:585:35)
    at invokeTask (zone.js:491:21)
    at ZoneTask.invoke (zone.js:476:48)

What am I missing? Other AngularFire modules are working just fine, e.g. Firestore.

My dependencies:

"firebase": "9.8.0",
"@angular/fire": "7.3.0",
"@angular/core": "~13.3.1"

Update: I've been trying to fix this for quite a while. Suddenly functions started working, but then @angular/fire/messaging stopped. At one point I also had @angular/fire/firestore not working. It seems like there's always one of the providers that doesn't work, while all the others do, but it seems random which one it is. I'm running out of ideas..



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source