Open lebolo opened 9 years ago
Could it be that only one stream.on("end"... is allowed, so that your overridden event handled disables the one that calls done()?
@lebolo Closing the cursor means closing the connection associated with it. Sometimes you want to keep the connection alive so other queries take place. I believe that's the reason QueryStream#close
is meant to be called manually.
Also, please notice that pg manages its own connection pool and certainly there's a time limit where idle connections are closed automatically and removed from the pool. So I believe pg or pg-query-stream are not causing you a huge memory footprint.
When I use pg-stream, the
QueryStream.close
function never gets called.I'm using pg-stream within a deferred function:
Then I call that function and use the resolved stream:
I first noticed this because I would get a huge memory footprint when I used the stream. I placed some
console.log
messages withinQueryStream.close
and never saw them (even though I see pg-stream, jsoncsv and response end messages).My workaround is to explicitly call
QueryStream.close
on the stream'send
event (commented out above). But is this expected?P.S.: @brianc thanks for all the great pg libraries!