diff --git a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts index 93678d8d95..a2cb7c8368 100644 --- a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts +++ b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts @@ -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; + } } diff --git a/superset-frontend/src/featureFlags.ts b/superset-frontend/src/featureFlags.ts index 4d457fd527..ba902f07df 100644 --- a/superset-frontend/src/featureFlags.ts +++ b/superset-frontend/src/featureFlags.ts @@ -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; + } }