Skip to content

Commit 3d4375b

Browse files
Added a fix for POSTGRES_CONNECTION_STRING_PATH error handling
Signed-off-by: Aayush Chouhan <[email protected]>
1 parent 0bf3bf6 commit 3d4375b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/util/postgres_client.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,10 +1500,14 @@ class PostgresClient extends EventEmitter {
15001500

15011501
if (process.env.POSTGRES_CONNECTION_STRING_PATH) {
15021502
/** @type {import('pg').PoolConfig} */
1503-
this.new_pool_params = {
1504-
connectionString: fs.readFileSync(process.env.POSTGRES_CONNECTION_STRING_PATH, "utf8"),
1505-
...params,
1506-
};
1503+
try {
1504+
this.new_pool_params = {
1505+
connectionString: fs.readFileSync(process.env.POSTGRES_CONNECTION_STRING_PATH, "utf8"),
1506+
...params,
1507+
};
1508+
} catch (err) {
1509+
throw new Error(`Failed to read connection string file '${process.env.POSTGRES_CONNECTION_STRING_PATH}': ${err.message}`);
1510+
}
15071511
} else {
15081512
// get the connection configuration. first from env, then from file, then default
15091513
const host = process.env.POSTGRES_HOST || fs_utils.try_read_file_sync(process.env.POSTGRES_HOST_PATH) || '127.0.0.1';

0 commit comments

Comments
 (0)