Skip to content

Commit 1f2c7e8

Browse files
author
Petr Kachanovsky
committed
fix postgres setup
1 parent 945f1d2 commit 1f2c7e8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

adminforth/dataConnectors/postgres.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ const { Client } = pkg;
88

99
class PostgresConnector extends AdminForthBaseConnector implements IAdminForthDataSourceConnector {
1010

11-
async setupClient(url): Promise<void> {
11+
async setupClient(url: string): Promise<void> {
1212
this.client = new Client({
1313
connectionString: url
1414
});
1515
try {
1616
await this.client.connect();
17-
this.client.on('error', (err) => {
17+
this.client.on('error', async (err) => {
1818
console.log('Postgres error: ', err.message, err.stack)
1919
this.client.end();
20-
this.client = new PostgresConnector({ url }).db;
20+
await new Promise((resolve) => { setTimeout(resolve, 1000) });
21+
this.setupClient(url);
2122
});
2223
} catch (e) {
2324
throw new Error(`Failed to connect to Postgres ${e}`);

0 commit comments

Comments
 (0)