diff --git a/src/util/postgres_client.js b/src/util/postgres_client.js index 16ffa0359a..13509927ce 100644 --- a/src/util/postgres_client.js +++ b/src/util/postgres_client.js @@ -1500,10 +1500,14 @@ class PostgresClient extends EventEmitter { if (process.env.POSTGRES_CONNECTION_STRING_PATH) { /** @type {import('pg').PoolConfig} */ - this.new_pool_params = { - connectionString: fs.readFileSync(process.env.POSTGRES_CONNECTION_STRING_PATH, "utf8"), - ...params, - }; + try { + this.new_pool_params = { + connectionString: fs.readFileSync(process.env.POSTGRES_CONNECTION_STRING_PATH, "utf8"), + ...params, + }; + } catch (err) { + throw new Error(`Failed to read connection string file '${process.env.POSTGRES_CONNECTION_STRING_PATH}': ${err.message}`); + } } else { // get the connection configuration. first from env, then from file, then default const host = process.env.POSTGRES_HOST || fs_utils.try_read_file_sync(process.env.POSTGRES_HOST_PATH) || '127.0.0.1';