Don't crash if we are unable to get a response from the feature-flag endpoint.
This commit is contained in:
parent
d8c9c723a5
commit
01fa64cb90
3 changed files with 17 additions and 5 deletions
|
|
@ -31,14 +31,21 @@ export class GitHubFeatureFlags implements FeatureFlags {
|
|||
) {}
|
||||
|
||||
async getValue(flag: FeatureFlag): Promise<boolean> {
|
||||
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;
|
||||
}
|
||||
|
||||
private async getApiResponse(): Promise<FeatureFlagsApiResponse> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue