1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-05 17:53:12 +02:00

fix: cherry-pick changes from main (#6143)

Co-authored-by: Mateusz Kwasniewski <kwasniewski.mateusz@gmail.com>
This commit is contained in:
Gastón Fournier 2024-02-06 16:32:50 +01:00 committed by GitHub
parent a8d71cf8fe
commit cc1cfad070
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 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

@ -128,6 +128,7 @@ export class ProxyService {
storageProvider: new InMemStorageProvider(),
disableMetrics: true,
repository,
disableAutoStart: true,
});
client.on(UnleashEvents.Error, (error) => {

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 [];
}
}