Open
Description
When trying to connect to a Postgres instance with SSL enabled, but the server didn't enable SSL, we get a "The server does not support SSL connections" as expected. But it does not close the underlying socket and it is leaked, preventing the node process from closing. It will hang for a few seconds/milliseconds until the next GC cycle runs to collect and close the socket.
import pg from "pg";
const client = new pg.Pool({
connectionString: process.env.CONNECTION_STRING,
ssl: { rejectUnauthorized: false },
});
try {
await client.connect();
} catch (e) {
console.log(e);
} finally {
await client.end();
}
console.log("done");
This snippet should run and exit immediatelly after showing "done" on the console.
This issue relates to #2720. There are situations where we don't know ahead of time if the database supports SSL or not, and we must try connecting with and without ssl. This is an issue for short-lived applications, such as a migration runner.
Metadata
Metadata
Assignees
Labels
No labels