Make sure to release all db connections

This commit is contained in:
nymkappa 2022-01-20 23:07:20 +09:00
parent 19a564062b
commit a1a2e9363f
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04

View File

@ -67,7 +67,14 @@ class PoolsParser {
// Get existing pools from the db
const connection = await DB.pool.getConnection();
const [existingPools] = await connection.query<any>({ sql: 'SELECT * FROM pools;', timeout: 120000 });
let existingPools: any[] = [];
try {
existingPools = await connection.query<any>({ sql: 'SELECT * FROM pools;', timeout: 120000 });
} catch (e) {
logger.err('Unable to get existing pools from the database, skipping pools.json import');
connection.release();
return;
}
// Finally, we generate the final consolidated pools data
const finalPoolDataAdd: Pool[] = [];
@ -158,6 +165,8 @@ class PoolsParser {
} catch (e) {
logger.err('Unable to insert "Unknown" mining pool');
}
connection.release();
}
}