Skip to content

Conversation

@davidmigloz
Copy link

@davidmigloz davidmigloz commented Dec 19, 2025

Summary

  • Adds a proactive check in the apps getter to verify if the Firebase core module is loaded before accessing firebase.apps
  • This avoids triggering a JavaScript exception when Firebase is not initialized, ensuring consistent behavior in both JS and WASM web builds

Fixes #17918

Changes

packages/firebase_core/firebase_core_web/lib/src/firebase_core_web.dart

Added a check using the existing pattern from _initializeCore():

if (globalContext.getProperty('firebase_core'.toJS) == null) {
  return [];
}

packages/firebase_core/firebase_core_web/test/firebase_core_web_exceptions_test.dart

Added a test to verify apps returns an empty list when Firebase is not initialized.

Test plan

  • Added unit test for the apps getter
  • All existing tests pass (flutter test --platform chrome)
  • Manual verification in WASM mode:
    flutter run -d chrome --release --wasm
    # Access Firebase.apps before initializeApp() - should return []

🤖 Generated with Claude Code

@gemini-code-assist
Copy link

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

@google-cla
Copy link

google-cla bot commented Dec 19, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Fixes firebase#17918

The `apps` getter now checks if the Firebase core module is loaded before
accessing `firebase.apps`. This avoids triggering a JavaScript exception
when Firebase is not initialized, which is more efficient than relying
on exception handling.

This change ensures `Firebase.apps` returns an empty list in both JS and
WASM web builds when called before `Firebase.initializeApp()`.
@davidmigloz davidmigloz force-pushed the fix/firebase-core-web-apps-wasm branch from e89cfd2 to 4820a7b Compare December 19, 2025 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[firebase_core_web] Firebase.apps getter throws uncaught JavaScriptError in WASM mode

1 participant