Skip to content

Commit

Permalink
Add warnings if feature flags are read before initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
codyml committed Aug 25, 2022
1 parent 17ad0d8 commit 20298a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,13 @@ declare global {
}

export function isFeatureEnabled(feature: FeatureFlag) {
return window && window.featureFlags && !!window.featureFlags[feature];
try {
return !!window.featureFlags[feature];
} catch (error) {
// eslint-disable-next-line no-console
console.error(`Failed to query feature flag ${feature} (see error below)`);
// eslint-disable-next-line no-console
console.error(error);
return false;
}
}
10 changes: 9 additions & 1 deletion superset-frontend/src/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@ export function initFeatureFlags(featureFlags: FeatureFlagMap) {
}

export function isFeatureEnabled(feature: FeatureFlag) {
return window && window.featureFlags && !!window.featureFlags[feature];
try {
return !!window.featureFlags[feature];
} catch (error) {
// eslint-disable-next-line no-console
console.error(`Failed to query feature flag ${feature} (see error below)`);
// eslint-disable-next-line no-console
console.error(error);
return false;
}
}

0 comments on commit 20298a5

Please sign in to comment.