1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: proxy repository error handling (#6142)

This commit is contained in:
Mateusz Kwasniewski 2024-02-06 15:44:25 +01:00 committed by GitHub
parent 067d130a8b
commit cc060b7a4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 11 deletions

View File

@ -64,7 +64,7 @@ export class ProxyRepository
this.configurationRevisionService =
services.configurationRevisionService;
this.token = token;
this.onAnyEvent = this.onAnyEvent.bind(this);
this.onUpdateRevisionEvent = this.onUpdateRevisionEvent.bind(this);
this.interval = config.frontendApi.refreshIntervalInMs;
}
@ -87,14 +87,20 @@ export class ProxyRepository
// Reload cached token data whenever something relevant has changed.
// For now, simply reload all the data on any EventStore event.
this.configurationRevisionService.on(UPDATE_REVISION, this.onAnyEvent);
this.configurationRevisionService.on(
UPDATE_REVISION,
this.onUpdateRevisionEvent,
);
this.emit(UnleashEvents.Ready);
this.emit(UnleashEvents.Changed);
}
stop(): void {
this.configurationRevisionService.off(UPDATE_REVISION, this.onAnyEvent);
this.configurationRevisionService.off(
UPDATE_REVISION,
this.onUpdateRevisionEvent,
);
this.running = false;
}
@ -122,7 +128,7 @@ export class ProxyRepository
this.features = await this.featuresForToken();
this.segments = await this.segmentsForToken();
} catch (e) {
this.logger.error(e);
this.logger.error('Cannot load data for token', e);
}
}
@ -130,12 +136,8 @@ export class ProxyRepository
return Math.floor(Math.random() * (ceiling - floor) + floor);
}
private async onAnyEvent() {
try {
await this.loadDataForToken();
} catch (error) {
this.logger.error(error);
}
private async onUpdateRevisionEvent() {
await this.loadDataForToken();
}
private async featuresForToken(): Promise<FeatureInterface[]> {

View File

@ -27,7 +27,7 @@ export default class UserFeedbackService {
try {
return await this.userFeedbackStore.getAllUserFeedback(user.id);
} catch (err) {
this.logger.error(err);
this.logger.error('Cannot read user feedback', err);
return [];
}
}