mitya2364
01/05/2024, 6:51 PMError: Connection terminated unexpectedly
from Postgres.
This only happens when using the DB within Wrangler. I have another, non-Wrangler app that connects to the same DB in the same way and via the same connection string, and it's fine. The DB is up, and showing no signs of issues.
Here's the util my controllers call to connect to and run a query on my DB:
export const query = async (q, params) => {
const client = new Client({
connectionString: env[env.DB+'-db'].connectionString,
ssl: {rejectUnauthorized: false}
});
await client.connect();
const res = await client.query(q, params);
return res;
};
The DB connection string is in my TOML under [[Hyperdrive]]
.
If I console.log(client)
right after connecting, it shows readyForQuery: true
. But when I then run a query, I get this error.
Sorry if this is not related to Wrangler but as I say, it's not happening in non-Wrangler setups with the same DB connection code.
Any idea what might be up?jshuff
01/12/2024, 2:27 PMmitya2364
01/12/2024, 2:46 PM