You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there is a problem with ending the pool.
When I terminate the pool within a teardown function without explicitly terminating the client, I get a "Leaking resources" error.
When I explicitly end the client, I don't get an error. Same for transactions.
The problem for tests is, that the functions under test should use several connections from the pool. When all test work is done one simply wants to shut down the pool.
In node projects I use https://github.com/brianc/node-postgres and that works as expected, so I think this behavior here is not correct.
Currently my solution is to terminate each client after use, but I don't think that's how it's meant to be used. Furthermore, this does not always work in the case of Transaction.
Can you confirm, this is an error or wrong behavior. If need be I can switch to node-postgres, but I would like to use a deno first lib.
I'm using:
Deno 1.34.2
deno-postgres 0.17.0
A simple Test is here:
import{afterAll,describe,it}from"https://deno.land/[email protected]/testing/bdd.ts";import{Pool}from"https://deno.land/x/[email protected]/mod.ts";import{assertEquals}from"https://deno.land/x/[email protected]/deps.ts";constdbPool=newPool({user: "myUser",database: "myDb",port: 5432,host_type: "socket",},1,true);describe("end pool",()=>{afterAll(async()=>{console.log("afterAll");awaitdbPool.end();});constdoQuery=async(query: string)=>{constclient=awaitdbPool.connect();letdbResult;try{dbResult=awaitclient.queryArray(query);}catch(err){console.log(err);throwerr;}finally{client.release();// client.end();}returndbResult;};it("should end all released clients if the db pool is ended",async()=>{constresult=awaitdoQuery("select 1").then((res)=>res.rows?.[0]?.[0]);assertEquals(result,1);});});
The text was updated successfully, but these errors were encountered:
I think there is a problem with ending the pool.
When I terminate the pool within a teardown function without explicitly terminating the client, I get a "Leaking resources" error.
When I explicitly end the client, I don't get an error. Same for transactions.
The problem for tests is, that the functions under test should use several connections from the pool. When all test work is done one simply wants to shut down the pool.
In node projects I use https://github.com/brianc/node-postgres and that works as expected, so I think this behavior here is not correct.
Currently my solution is to terminate each client after use, but I don't think that's how it's meant to be used. Furthermore, this does not always work in the case of Transaction.
Can you confirm, this is an error or wrong behavior. If need be I can switch to node-postgres, but I would like to use a deno first lib.
I'm using:
A simple Test is here:
The text was updated successfully, but these errors were encountered: