From 81540318b4c55f3a09c9776e23d2211abdbd36f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 5 Sep 2024 09:31:08 +0200 Subject: [PATCH] feat(core): Make Postgres connection timeout configurable (#10670) --- packages/@n8n/config/src/configs/database.config.ts | 4 ++++ packages/@n8n/config/test/config.test.ts | 1 + packages/cli/src/databases/config.ts | 1 + 3 files changed, 6 insertions(+) diff --git a/packages/@n8n/config/src/configs/database.config.ts b/packages/@n8n/config/src/configs/database.config.ts index 9da83958e6da0..785d91b4bfd52 100644 --- a/packages/@n8n/config/src/configs/database.config.ts +++ b/packages/@n8n/config/src/configs/database.config.ts @@ -75,6 +75,10 @@ class PostgresConfig { @Env('DB_POSTGRESDB_POOL_SIZE') poolSize: number = 2; + /** Postgres connection timeout (ms) */ + @Env('DB_POSTGRESDB_CONNECTION_TIMEOUT') + connectionTimeoutMs: number = 1000; + @Nested ssl: PostgresSSLConfig; } diff --git a/packages/@n8n/config/test/config.test.ts b/packages/@n8n/config/test/config.test.ts index 149cb1abbe7f0..ecb254184a038 100644 --- a/packages/@n8n/config/test/config.test.ts +++ b/packages/@n8n/config/test/config.test.ts @@ -47,6 +47,7 @@ describe('GlobalConfig', () => { poolSize: 2, port: 5432, schema: 'public', + connectionTimeoutMs: 1000, ssl: { ca: '', cert: '', diff --git a/packages/cli/src/databases/config.ts b/packages/cli/src/databases/config.ts index 1f8c748fa7afe..9c4562d3d6652 100644 --- a/packages/cli/src/databases/config.ts +++ b/packages/cli/src/databases/config.ts @@ -104,6 +104,7 @@ const getPostgresConnectionOptions = (): PostgresConnectionOptions => { schema: postgresConfig.schema, poolSize: postgresConfig.poolSize, migrations: postgresMigrations, + connectTimeoutMS: postgresConfig.connectionTimeoutMs, ssl, }; };