Skip to content

Pr to resolve some doubts #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions packages/pg-query-stream/test/pool-query-stream-close.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import helper from "./helper";
import QueryStream from "../src";
import pg from "pg";


describe("Pool Query-Stream", function() {

it('releases pool connection after end of query stream', async function() {
const pool = new pg.Pool();
// const client = await pool.connect();
const query = new QueryStream('SELECT NOW()');
const stream = pool.query(query);

query.on('end',async(res)=>{
console.log('query stream ended');
});

// bellow code raising error as stream .on is not a function
console.log(await stream); // this never gets resolved;
stream.on('end',async (res)=>{
console.log(res);
await pool.end();
console.log('stream ended');
await Promise.resolve();
})

})

})