mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-11 00:08:30 +01:00
fix: proxy repository error handling (#6142)
This commit is contained in:
parent
067d130a8b
commit
cc060b7a4c
@ -64,7 +64,7 @@ export class ProxyRepository
|
|||||||
this.configurationRevisionService =
|
this.configurationRevisionService =
|
||||||
services.configurationRevisionService;
|
services.configurationRevisionService;
|
||||||
this.token = token;
|
this.token = token;
|
||||||
this.onAnyEvent = this.onAnyEvent.bind(this);
|
this.onUpdateRevisionEvent = this.onUpdateRevisionEvent.bind(this);
|
||||||
this.interval = config.frontendApi.refreshIntervalInMs;
|
this.interval = config.frontendApi.refreshIntervalInMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,14 +87,20 @@ export class ProxyRepository
|
|||||||
|
|
||||||
// Reload cached token data whenever something relevant has changed.
|
// Reload cached token data whenever something relevant has changed.
|
||||||
// For now, simply reload all the data on any EventStore event.
|
// 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.Ready);
|
||||||
this.emit(UnleashEvents.Changed);
|
this.emit(UnleashEvents.Changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
stop(): void {
|
stop(): void {
|
||||||
this.configurationRevisionService.off(UPDATE_REVISION, this.onAnyEvent);
|
this.configurationRevisionService.off(
|
||||||
|
UPDATE_REVISION,
|
||||||
|
this.onUpdateRevisionEvent,
|
||||||
|
);
|
||||||
this.running = false;
|
this.running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +128,7 @@ export class ProxyRepository
|
|||||||
this.features = await this.featuresForToken();
|
this.features = await this.featuresForToken();
|
||||||
this.segments = await this.segmentsForToken();
|
this.segments = await this.segmentsForToken();
|
||||||
} catch (e) {
|
} 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);
|
return Math.floor(Math.random() * (ceiling - floor) + floor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async onAnyEvent() {
|
private async onUpdateRevisionEvent() {
|
||||||
try {
|
await this.loadDataForToken();
|
||||||
await this.loadDataForToken();
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async featuresForToken(): Promise<FeatureInterface[]> {
|
private async featuresForToken(): Promise<FeatureInterface[]> {
|
||||||
|
@ -27,7 +27,7 @@ export default class UserFeedbackService {
|
|||||||
try {
|
try {
|
||||||
return await this.userFeedbackStore.getAllUserFeedback(user.id);
|
return await this.userFeedbackStore.getAllUserFeedback(user.id);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error(err);
|
this.logger.error('Cannot read user feedback', err);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user