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

Merged
merged 1 commit into from
Apr 1, 2025

Conversation

henribru
Copy link
Contributor

@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

CLAassistant commented Feb 24, 2025

CLA assistant check
All committers have signed the CLA.

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
Contributor 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.

@mikehardy mikehardy added type: bug New bug report tools: typings TypeScript / Flow Workflow: Needs Review Pending feedback or review from a maintainer. labels Mar 21, 2025
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.

I believe this is correct - thanks @henribru

@mikehardy
Copy link
Collaborator

@henribru I just noticed - you haven't signed the CLA for react-native-firebase yet, could you follow the details link and do so? Then I can get this merged. I believe you just need to do so once and it will cover the other PR(s) you have open at same time. Thanks!

@mikehardy mikehardy added Blocked: Missing CLA Workflow: Pending Merge Waiting on CI or similar and removed Workflow: Needs Review Pending feedback or review from a maintainer. Needs Attention Workflow: Pending Merge Waiting on CI or similar labels Mar 27, 2025
Copy link
Collaborator

@MichaelVerdon MichaelVerdon left a comment

Choose a reason for hiding this comment

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

LGTM

@henribru
Copy link
Contributor Author

henribru commented Apr 1, 2025

@henribru I just noticed - you haven't signed the CLA for react-native-firebase yet, could you follow the details link and do so? Then I can get this merged. I believe you just need to do so once and it will cover the other PR(s) you have open at same time. Thanks!

Done!

@mikehardy mikehardy merged commit 5189c32 into invertase:main Apr 1, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools: typings TypeScript / Flow type: bug New bug report
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants