porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.09k stars 259 forks source link

Trying to reserve a connection without previously executing any sql hangs indefinitely. #751

Open mikeburgh opened 7 months ago

mikeburgh commented 7 months ago

This does not happen unless fetch_types is set to false which means no connections are attempted before the reserve. If you leave fetch_types alone, or perform another sql opteration first, it works.

Using the latest version:

const postgres = require('postgres');

async function main() {
    const sql = postgres({
        host: '127.0.0.1',
        port: 5432,
        user: 'postgres',
        password: 'postgres',
        database: 'postgres',
        fetch_types: false
    });

    console.log('Starting');
    const reserved = await sql.reserve();
    console.log(await reserved`select 1`);
    console.log('done');
    reserved.release();
}

main();
tim-smart commented 5 months ago

Related: https://github.com/porsager/postgres/commit/c084a1cf0ffd5aeaf9388ef0c84d0da28fca24b5#r131741037