Skip to content

[Bug]: Firebase App Check import/initialization according to documentation causes runtime errors #7288

@whats-a-handle

Description

@whats-a-handle

Operating System

MacOS Ventura 13.2.1

Browser Version

ChromeVersion 113.0.5672.92 (Official Build) (x86_64)

Firebase SDK Version

9.21

Firebase SDK Product:

Analytics, AppCheck, Auth, Firestore, Functions

Describe your project's tooling

ReactJS with Create React App

Describe the problem

I have been using firebase js v9.15 for a while now, and decided to update to v9.21 to leverage the new App Check functionality that was added for the new Firebase IAM Authentication (beta). Ive been using AppCheck to secure my Firestore, and I have not had any issues with that functionality so I know I have a valid AppCheck config for the last few months.

Upon updating to 9.21, I began to receive Uncaught Runtime errors in my local environment stating that Component app-check has not been registered yet. I had not changed the way I initialized and imported initializeAppCheck and ReCaptchaV3Provider as I had been following the official documentation for months https://firebase.google.com/docs/app-check/web/recaptcha-provider#initialize.

Runtime error

Screenshot 2023-05-09 at 10 50 01 PM


firebase.js is where I initialize firebase, auth, and appcheck

Screenshot 2023-05-09 at 10 50 16 PM


Official Firebase js provider.ts file

Screenshot 2023-05-09 at 10 51 22 PM

Steps and code to reproduce issue

Follow the Firebase documentation to initialize AppCheck for Web v9 and use firebase js v9.21.
https://firebase.google.com/docs/app-check/web/recaptcha-provider#initialize

import { initializeApp } from 'firebase/app';

const { initializeAppCheck, ReCaptchaV3Provider } = require('firebase/app-check'); //this causes the error
const app = initializeApp(<Your firebase config>);

window.self.FIREBASE_APPCHECK_DEBUG_TOKEN = <Your Debug Token>

const appCheck = initializeAppCheck(app, {
  provider: new ReCaptchaV3Provider(<App Check Key>),
  isTokenAutoRefreshEnabled: true,
});

You should receive an uncaught error stating that Component app-check has not been registered yet

Solution or Workaround

Import initializeAppCheck and ReCaptchaV3Provider like so, and it works as expected. Not sure if the official documentation needs to be updated or what. I repro'd this issue in a clean repo outside of my main project where I discovered this issue as well.

import {initializeAppCheck,ReCaptchaV3Provider} from 'firebase/app-check'

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions