refactor(Postgres Node): Backport connection pooling to postgres v1 (#12484)

This commit is contained in:
Danny Martini
2025-01-16 11:09:12 +01:00
committed by GitHub
parent c97bd48a77
commit 35cb10c5e7
12 changed files with 49 additions and 69 deletions

View File

@@ -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 {