firebase / firebase-js-sdk

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

All remote config param values are not returned on App A but are returned on App B #8172

Closed enterprisecoderr closed 1 month ago

enterprisecoderr commented 1 month ago

Operating System

MacOS Sonoma 14.3

Browser Version

Chrome Version 123.0.6312.124 (Official Build) (arm64)

Firebase SDK Version

0.9.27

Firebase SDK Product:

Remote-Config

Describe your project's tooling

Stencil Application with webpack.

Versions of the firebase deps: "@firebase/app": "0.9.27", "@firebase/remote-config": "0.4.6",

Describe the problem

I am unable to get all parameters from remote config when using it inside my stencil appllication

Steps and code to reproduce issue

I create a firebase app with the following code. Ignore any missing imports as they are hidden intentionally. No compilation issues just runtime issues.

import { initializeApp } from '@firebase/app';

export const app = initializeApp(...);

I then utilize the app to get the remote config object in this remote config service

import { FirebaseApp } from '@firebase/app';
import { RemoteConfig, Value, activate, fetchConfig, getAll, getRemoteConfig, getString, getValue } from '@firebase/remote-config';
import { WEB_REMOTE_CONFIG_NAME } from '../constants/FIREBASE';
import { FirebaseService} from './firebase.service';

export class RemoteConfigService {
  initialized: boolean;
  private firebaseApp?: FirebaseApp;
  private remoteConfig?: RemoteConfig;

  constructor(private firebaseService: FirebaseService) {
    this.initialized = false;
    this.init();
  }

  public async init(): Promise<void> {
    this.firebaseApp = this.firebaseService.getFirebaseApp();
    this.remoteConfig = getRemoteConfig(this.firebaseApp);
    await this.activeLastAndFetchLatestForNextLogin();
    this.setConfigSettings();
    this.initialized = true;
  }

  private setConfigSettings() {
    const inProd = true;

    if (inProd) {
      this.remoteConfig.settings.minimumFetchIntervalMillis = 0;
    }
  }

  private async activeLastAndFetchLatestForNextLogin(): Promise<void> {
    if (this.remoteConfig) {

      await activate(this.remoteConfig);

      await fetchConfig(this.remoteConfig);

      if (this.remoteConfig.lastFetchStatus === 'failure') {
        this.logger.error('Failed to fetch latest firebase remote config');
      }
    }
  }
}

export const defaultRemoteConfigService = new RemoteConfigService(new LoggerFactory(), defaultFirebaseService);

Upon checking the firebase_remote_config.app_namespace_store table in indexedDB under the Application tab in the chrome browser, all the remote config parameters are not shown, which is inconsistent with what I see inside the firebase console

google-oss-bot commented 1 month ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

enterprisecoderr commented 1 month ago

I'd like to add that App B uses angular/fire in an Angular application to setup firebase and get remote config params.

I also ran both apps referencing the same remote config at the same time in the same browser window. Could it be that behind the scenes the browser level setup for remote config fails to support two unique subscriber instances?

enterprisecoderr commented 1 month ago

Figured out solution was I was passing in an inaccurate config that was being loaded at runtime