postgres icon indicating copy to clipboard operation
postgres copied to clipboard

BUG: If a query fails, it never ends

Open Llorx opened this issue 3 months ago • 0 comments

I have this code:

try {
    await pg.unsafe("My query");
} catch (e) {
    // whatever
}

The connection is inmediately lost as a test that I have is to close the server socket just when the query starts, so I'm receiving an Error: read ECONNRESET in the catch.

But when I try to end the connection, it lasts forever:

await pg.end();

I went into the code and what I found is that a connection has a rejected query associated, so it just waits for it to finish, but it is already finished, so it waits forever:

Image

Obviously I don't want to add a timeout to the end callback as a workaround. All resources should be cleaned properly.

Llorx avatar Oct 17 '25 09:10 Llorx