Supabase pooler causing Node.js server crash after DB query

I'm using a Node.js backend with Express and the pg package to connect to a Supabase (Free Tier) PostgreSQL database. I'm connecting through the Supabase connection pooler (aws-0-ap-south-1.pooler.supabase.com) with SSL enabled (rejectUnauthorized: false). The server starts up fine. When I send a login request via Postman, it completes successfully and returns a token. But immediately after that, the server crashes. The same thing happens when I try to access a dashboard route that makes a query using the same pool connection.Tjhe route responds once, then the server crashes and has to be restarted. Here's my DB connection code:
const pool = new Pool({
user: process.env.DB_USER,
host: process.env.DB_HOST,
database: process.env.DB_NAME,
password: process.env.DB_PASSWORD,
port: process.env.DB_PORT,
ssl: {
rejectUnauthorized: false
}
});
const pool = new Pool({
user: process.env.DB_USER,
host: process.env.DB_HOST,
database: process.env.DB_NAME,
password: process.env.DB_PASSWORD,
port: process.env.DB_PORT,
ssl: {
rejectUnauthorized: false
}
});
The error I'm getting is:
node:events:496
throw er; // Unhandled 'error' event
^

error: {:shutdown, :db_termination}
at Parser.parseErrorMessage (node_modules/pg-protocol/dist/parser.js:285:98)
...

node:events:496
throw er; // Unhandled 'error' event
^

error: {:shutdown, :db_termination}
at Parser.parseErrorMessage (node_modules/pg-protocol/dist/parser.js:285:98)
...

Has anyone run into this when using the Supabase connection pooler? Not sure if it's something to do with Supabase shutting down idle clients, the Free Tier limitations, or something wrong with my connection setup. I'm on Windows 11 and using pg@8.11.3. Would appreciate any ideas on what might be causing this or how to prevent the crash.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?