mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(Postgres Node): Backport connection pooling to postgres v1 (#12484)
This commit is contained in:
@@ -4,8 +4,8 @@ import type {
|
||||
INodeCredentialTestResult,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { PgpClient, PostgresNodeCredentials } from '../helpers/interfaces';
|
||||
import { configurePostgres } from '../transport';
|
||||
import { configurePostgres } from '../../transport';
|
||||
import type { PgpConnection, PostgresNodeCredentials } from '../helpers/interfaces';
|
||||
|
||||
export async function postgresConnectionTest(
|
||||
this: ICredentialTestFunctions,
|
||||
@@ -13,14 +13,12 @@ export async function postgresConnectionTest(
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
const credentials = credential.data as PostgresNodeCredentials;
|
||||
|
||||
let pgpClientCreated: PgpClient | undefined;
|
||||
let connection: PgpConnection | undefined;
|
||||
|
||||
try {
|
||||
const { db, pgp } = await configurePostgres.call(this, credentials, {});
|
||||
const { db } = await configurePostgres.call(this, credentials, {});
|
||||
|
||||
pgpClientCreated = pgp;
|
||||
|
||||
await db.connect();
|
||||
connection = await db.connect();
|
||||
} catch (error) {
|
||||
let message = error.message as string;
|
||||
|
||||
@@ -41,8 +39,8 @@ export async function postgresConnectionTest(
|
||||
message,
|
||||
};
|
||||
} finally {
|
||||
if (pgpClientCreated) {
|
||||
pgpClientCreated.end();
|
||||
if (connection) {
|
||||
await connection.done();
|
||||
}
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user