Don't crash if we are unable to get a response from the feature-flag endpoint.

This commit is contained in:
Cornelius Riemenschneider
2022-07-18 10:14:40 +00:00
committed by GitHub
parent d8c9c723a5
commit 01fa64cb90
3 changed files with 17 additions and 5 deletions

9
lib/feature-flags.js generated
View File

@@ -35,12 +35,17 @@ class GitHubFeatureFlags {
this.logger = logger;
}
async getValue(flag) {
const response = (await this.getApiResponse())[flag];
const response = await this.getApiResponse();
if (response === undefined) {
this.logger.debug(`No feature flags API response for ${flag}, considering it disabled.`);
return false;
}
const flag_value = response[flag];
if (flag_value === undefined) {
this.logger.debug(`Feature flag '${flag}' undefined in API response, considering it disabled.`);
return false;
}
return response;
return flag_value;
}
async getApiResponse() {
const loadApiResponse = async () => {