Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): annotate initializeApp return as a promise #8366

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

henribru
Copy link

@henribru henribru commented Feb 24, 2025

Description

initializeApp in the modular API is annotated is returning the app directly, but like in the namespaced API it actually returns a promise

Related issues

Release Summary

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
    • Other (macOS, web)
  • My change includes tests; N/A
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

N/A

Copy link

vercel bot commented Feb 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-firebase ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 24, 2025 3:47pm

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Collaborator

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately we can't accept this change

1- it must return AppCheck, not FirebaseApp (note! currently this is an implementation change, but it's an important one and we need to do it ASAP

2- it should not return a Promise, that's a difference from firebase-js-sdk and there's no technical reason to do it

reference ref: https://firebase.google.com/docs/reference/js/app-check.md#initializeappcheck_5548dfc

Separately: currently it is not returning a Promise anyway as far as I can tell?

1- getApp() (underlying source of the FirebaseApp that it is returning, though it should return AppCheck, is not async: https://github.com/invertase/react-native-firebase/blob/main/packages/app/lib/modular/index.d.ts#L55

2- implementation delegates but is not async https://github.com/invertase/react-native-firebase/blob/main/packages/app/lib/modular/index.js#L71

3- fundamental implementation is not async for getApp

export function getApp(name = DEFAULT_APP_NAME) {

So, I don't think it is a Promise currently, curious how you're seeing that

Regardless, cannot be Promise and cannot return FirebaseApp to correctly implement the firebase-js-sdk and meet our goal of being a drop-in replacement for firebase-js-sdk

@henribru
Copy link
Author

henribru commented Feb 24, 2025

You're linking the source for getApp, not initializeApp. initializeApp very much appears to return a promise: https://github.com/invertase/react-native-firebase/blob/main/packages/app/lib/internal/registry/app.js#L117

It is already annotated as such in the types for the namespaced API, the modular types are just inconsistent: https://github.com/invertase/react-native-firebase/blob/main/packages/app/lib/index.d.ts#L198 Maybe this is inconsistent with firebase-js-sdk, but if so it's not a new inconsistency in the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants