Skip to content

Commit

Permalink
Fix unsupported chains aggregation logs (#1978)
Browse files Browse the repository at this point in the history
- Fix unsupported chains logs.
  • Loading branch information
hectorgomezv authored Sep 30, 2024
1 parent 9bf3ca6 commit ea22492
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/domain/hooks/helpers/event-cache.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class EventCacheHelper implements OnModuleInit, OnModuleDestroy {
public isSupportedChainMemo: ((chainId: string) => Promise<boolean>) &
MemoizedFunction;
private unsupportedEventsLogTimer: NodeJS.Timeout | undefined;
private unsupportedChains: Array<string> = [];

constructor(
@Inject(IBalancesRepository)
Expand Down Expand Up @@ -153,6 +154,9 @@ export class EventCacheHelper implements OnModuleInit, OnModuleDestroy {
* @param event {@link Event} object
*/
public async onUnsupportedChainEvent(event: Event): Promise<void> {
if (!this.unsupportedChains.includes(event.chainId)) {
this.unsupportedChains.push(event.chainId);
}
const cacheKey = CacheRouter.getUnsupportedChainEventCacheKey(
event.chainId,
);
Expand Down Expand Up @@ -489,27 +493,26 @@ export class EventCacheHelper implements OnModuleInit, OnModuleDestroy {
): Array<Promise<void>> {
return [this.safeRepository.clearIsSafe(event)];
}

/**
* Logs the number of unsupported chain events for each chain and clears the store.
*/
private async _logUnsupportedEvents(): Promise<void> {
const chains = await this.chainsRepository.getChains();
await Promise.all(
chains.results.map(async (chain) => {
const cacheKey = CacheRouter.getUnsupportedChainEventCacheKey(
chain.chainId,
);
this.unsupportedChains.map(async (chainId) => {
const cacheKey = CacheRouter.getUnsupportedChainEventCacheKey(chainId);
const count = await this.cacheService.getCounter(cacheKey);
if (count) {
this.loggingService.warn({
type: EventCacheHelper.UNSUPPORTED_CHAIN_EVENT,
chainId: chain.chainId,
chainId,
count,
});
await this.cacheService.deleteByKey(cacheKey);
}
}),
);
this.unsupportedChains = [];
}

private _logSafeTxEvent(
Expand Down

0 comments on commit ea22492

Please sign in to comment.