Skip to content

Commit 729ba74

Browse files
committed
verify firebase config
1 parent 3fd56b8 commit 729ba74

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/modules/remote-config/plugins/firebase.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ export async function fetchRemoteConfig<T extends keyof RemoteConfig>(
3333

3434
let remoteConfig: RemoteConfig | undefined;
3535

36+
function isEmptyConfig(maybeConfig: Partial<RemoteConfig>) {
37+
if (!maybeConfig) {
38+
return true;
39+
}
40+
for (const knownKey of knownKeys) {
41+
if (knownKey in maybeConfig) {
42+
return false;
43+
}
44+
}
45+
return true;
46+
}
47+
3648
const REFRESH_RATE = 1000 * 60 * 5;
3749

3850
export const firebase: ConfigPlugin & { refresh(): void } = {
@@ -62,7 +74,10 @@ export const firebase: ConfigPlugin & { refresh(): void } = {
6274
* By doing this, we make the remoteConfig "eventually up-to-date"
6375
*/
6476
firebase.refresh();
65-
const config = remoteConfig ?? defaultConfig;
77+
const config =
78+
remoteConfig && !isEmptyConfig(remoteConfig)
79+
? remoteConfig
80+
: defaultConfig;
6681
const value = config[key];
6782
return { value };
6883
},

0 commit comments

Comments
 (0)