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
{{ message }}
This repository has been archived by the owner on Dec 27, 2019. It is now read-only.
When I use pg-stream, the QueryStream.close function never gets called.
I'm using pg-stream within a deferred function:
varpg=require('pg');varQ=require('q');varQueryStream=require('pg-query-stream');varsql= ...;varconnStr= ...;pg.connect(connStr,function(err,client,done){vardeferred=Q.defer();varqstream=newQueryStream(sql.text,sql.values,{highWaterMark: 10000,batchSize: 10000});varstream=client.query(qstream);stream.on('end',function(){//console.log('Manually closing cursor');//qstream.close();done();});stream.on('error',function(err){// An error occurred, return the client to the connection pooldone();});deferred.resolve(stream);});
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 within QueryStream.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's end event (commented out above). But is this expected?
P.S.: @brianc thanks for all the great pg libraries!
The text was updated successfully, but these errors were encountered:
@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.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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!
The text was updated successfully, but these errors were encountered: