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

remoteConfig().getAll() return undefined is not an object (evaluating 'Object.keys(this._values)') #5854

Closed
AghaShayan123 opened this issue Nov 16, 2021 · 4 comments · Fixed by #5859
Labels
plugin: remote_config Firebase Remote Config type: bug New bug report

Comments

@AghaShayan123
Copy link

AghaShayan123 commented Nov 16, 2021

useEffect(() => {
getConfig()
.then(res => console.log(res)
.catch(err => console.log(err.message))
}, [])

const getConfig = async () => {
const firebase = await remoteConfig().getAll();
return firebase
}

It return undefined is not an object (evaluating 'Object.keys(this._values)')

@AghaShayan123 AghaShayan123 added help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report labels Nov 16, 2021
@mikehardy
Copy link
Collaborator

We can reopen if you include version information as requested in the template you actively deleted

@mikehardy
Copy link
Collaborator

Also if reproducible on current versions please include full stack trace thrown, these are all things you would need if someone brought the problem to you I believe

@AghaShayan123
Copy link
Author

Also if reproducible on current versions please include full stack trace thrown, these are all things you would need if someone brought the problem to you I believe

These are my current versions list

"react": "17.0.2",
"react-native": "0.66.0",
"@react-native-firebase/analytics": "^13.0.1",
"@react-native-firebase/app": "^13.0.1",
"@react-native-firebase/auth": "^13.0.1",
"@react-native-firebase/firestore": "^13.0.1",
"@react-native-firebase/in-app-messaging": "^13.0.1",
"@react-native-firebase/messaging": "^13.0.1",
"@react-native-firebase/remote-config": "^13.0.1",

@mikehardy mikehardy reopened this Nov 16, 2021
@mikehardy
Copy link
Collaborator

Okay, I can see the problem. I'm going to increase validation in the effected area, but this is at heart a usage issue. It should not crash, but you are not using it correctly.

Prior to calling getAll or getValue, you must set defaults, and fetchAndActivate, until then you may not assume there is anything useful in the config's internal state, and in fact it is uninitialized at the moment

From our docs - https://rnfirebase.io/remote-config/usage#default-values

Before fetching the parameters from Firebase, it is first important to set some default values

And then again a very prescriptive statement in the next chunk https://rnfirebase.io/remote-config/usage#fetch--activate

Before reading the values from Firebase, we first need to pull them from Firebase (fetching) & then enable them on the device (activating). The fetchAndActivate API combines both tasks into a single flow

I am certain that will resolve your issue, and result in useful results so it will actually resolve the issue for you

@mikehardy mikehardy added plugin: remote_config Firebase Remote Config and removed help: needs-triage Issue needs additional investigation/triaging. labels Nov 16, 2021
mikehardy added a commit that referenced this issue Nov 16, 2021
previously if you incorrectly called getAll before setting defaults or fetching any
remote config, we would crash.

Now we initialize values as an empty object, so we have a graceful failure

confirmed via code inspection that this matches expecations from firebase-js-sdk
https://github.com/firebase/firebase-js-sdk/blob/acc58102d4429ce0593ec22192e76018e9d16ed7/packages/remote-config/test/remote_config.test.ts#L333-L335

Fixes #5854
mikehardy added a commit that referenced this issue Nov 16, 2021
previously if you incorrectly called getAll before setting defaults or fetching any
remote config, we would crash.

Now we initialize values as an empty object, so we have a graceful failure

confirmed via code inspection that this matches expecations from firebase-js-sdk
https://github.com/firebase/firebase-js-sdk/blob/acc58102d4429ce0593ec22192e76018e9d16ed7/packages/remote-config/test/remote_config.test.ts#L333-L335

Fixes #5854
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: remote_config Firebase Remote Config type: bug New bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants