Skip to content

Commit

Permalink
Merge pull request #738 from rocket-admin/backend_postgres_fix
Browse files Browse the repository at this point in the history
refactor: Add error handling for cachedKnex in KnexManager
  • Loading branch information
Artuomka authored Jul 17, 2024
2 parents d56a1a1 + 8d3297f commit 0b3ca56
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion shared-code/src/knex-manager/knex-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export class KnexManager {
knexMap.set('postgres', async (connection: ConnectionParams): Promise<Knex<any, any[]>> => {
const cachedKnex = knexCache.get(JSON.stringify(connection));
if (cachedKnex) {
return cachedKnex;
try {
await cachedKnex.raw('SELECT 1');
return cachedKnex;
} catch (error) {
knexCache.delete(JSON.stringify(connection));
}
}
if (connection.ssh) {
const newKnex = await KnexManager.createTunneledKnex(connection);
Expand Down

0 comments on commit 0b3ca56

Please sign in to comment.