Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

Fix redis client handle leak #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions scripts/saveApiResponses.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import fs from 'fs';
import redis from 'redis';
import { promisify } from 'util';
import { lookupGeoIP } from '../lib/geoIP.mjs';
import { withCache } from '../lib/cacheUtils.mjs';

process.on('unhandledRejection', up => { throw up });

Expand Down Expand Up @@ -46,9 +45,11 @@ async function updateBlockchainData(blockchain) {
const nodeAccounts = await api.loadNodeAccounts({ axios });
const nodeAccountsWithLocation = await Promise.all(nodeAccounts.map(async (nodeAccount) => {
const cacheKey = `nodeIP-${nodeAccount['ip_address']}`;
const lookup = await withCache(cacheKey, async () => {
return await lookupGeoIP(nodeAccount['ip_address']);
});
let lookup = await getAsync(cacheKey);
if (!lookup) {
lookup = await lookupGeoIP(nodeAccount['ip_address']);
setAsync(cacheKey, JSON.stringify(lookup))
}
return { ...nodeAccount, location: lookup };
}));
const lastBlock = await api.loadLastBlock({ axios });
Expand Down