pool.query(new QueryStream(...)) unexpected behaviour
See original GitHub issueHi,
if I use the query
method on pg.Pool with a query object that implements sumbit
(i.e. pg-query-stream or pg-cursor) like this:
import { Pool } from "pg";
import QueryStream = require("pg-query-stream");
const pool = new Pool();
// ...
const query = new QueryStream("SELECT * FROM ...");
const q = pool.query(query);
console.log(q); // Promise { <pending>, ...
await q; //!
the returned promise never resolves and the pool never releases the used client
I could ignore the return value and continue with the result, e.g.
for await (const row in query) { ...process row...}
but the client leak is a problem
furthermore, the typescript definition is plain wrong:
export class Pool extends events.EventEmitter {
// ...
query<T extends Submittable>(queryStream: T): T;
// ...
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
postgres query takes longer when streaming in node
This is how I query my data in Node : const {Pool} = require('pg'); const QueryStream = require('pg-query-stream'); const CSVStream ...
Read more >Serverless SQL pool self-help - Azure Synapse Analytics
Your query might fail with the error message Websocket connection was closed unexpectedly. This message means that your browser connection to ...
Read more >node-mssql | Microsoft SQL Server client for Node.js
The following example obtains the global connection pool by running sql.connect() , and then runs the query against the pool. NB: It's important...
Read more >Structured Streaming + Kafka Integration Guide (Kafka broker ...
Creating a Kafka Source for Streaming Queries. Scala; Java; Python ... However, do this with extreme caution as it can cause unexpected behavior....
Read more >Custom Serialization | Elasticsearch.Net and NEST
For the latest information, see the current release documentation. ... stream, CancellationToken cancellationToken = default(CancellationToken)) => throw ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve submitted a PR that fixes this 👀
#2810
yeah that sounds like a problem - I’ll definitely look at this. For now I think a workaround you can do is
Sorry for the hassle - i’ll get this fixed