@merkl/api 0.20.15 → 0.20.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,13 @@
1
1
  import { Redis } from "@/cache";
2
2
  import { getEulerV2Vaults, updateEulerVaultsCollatInDatabase } from "@/engine/dynamicData/utils/getEulerV2Vaults";
3
3
  (async () => {
4
- await Redis.safeSet("EulerV2Vaults", await getEulerV2Vaults());
5
- await updateEulerVaultsCollatInDatabase();
4
+ try {
5
+ await Redis.safeSet("EulerV2Vaults", await getEulerV2Vaults());
6
+ await updateEulerVaultsCollatInDatabase();
7
+ process.exit(1);
8
+ }
9
+ catch (error) {
10
+ console.error(error);
11
+ process.exit(1);
12
+ }
6
13
  })();
@@ -3,17 +3,18 @@ import { TTLPresets } from "@/modules/v4/cache/cache.model";
3
3
  import { ChainService } from "@/modules/v4/chain/chain.service";
4
4
  import { MerklRootRepository } from "@/modules/v4/merklRoot/merklRoot.repository";
5
5
  import { OpportunityService } from "@/modules/v4/opportunity";
6
- import { NETWORK_LABELS, log } from "@sdk";
6
+ import { NETWORK_LABELS, log, withTimeout } from "@sdk";
7
7
  const main = async () => {
8
- // ─── Refresh Cache For GET /opportunities ────
9
- await CacheService.set(TTLPresets.MIN_5, OpportunityService.findMany, { items: 25, page: 0 });
10
- await CacheService.set(TTLPresets.MIN_5, OpportunityService.findMany, { items: 50, page: 0 });
11
8
  try {
12
9
  const chains = await ChainService.getSupportedIds();
13
10
  const promises = [];
14
11
  for (const chain of chains)
15
- promises.push(CacheService.set(TTLPresets.MIN_10, MerklRootRepository.fetch, chain).catch(_err => log.warn(`RPC calls cache update failed for ${NETWORK_LABELS[chain]}.`)));
12
+ promises.push(withTimeout(CacheService.set(TTLPresets.MIN_30, MerklRootRepository.fetch, chain).catch(_err => log.warn(`RPC calls cache update failed for ${NETWORK_LABELS[chain]}.`)), 60_000 // There is no reason for this call to take more than 60 sec
13
+ ));
16
14
  await Promise.allSettled(promises);
15
+ // ─── Refresh Cache For GET /opportunities ────
16
+ await CacheService.set(TTLPresets.MIN_5, OpportunityService.findMany, { items: 25, page: 0 });
17
+ await CacheService.set(TTLPresets.MIN_5, OpportunityService.findMany, { items: 50, page: 0 });
17
18
  process.exit(0);
18
19
  }
19
20
  catch (err) {