File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ function Connection(options = {}) {
137137 : ( messages . push ( buffer ) , connect ( ) )
138138 } catch ( err ) {
139139 query . reject ( err )
140+ idle ( )
140141 }
141142 }
142143
@@ -178,8 +179,10 @@ function Connection(options = {}) {
178179 }
179180
180181 function idle ( ) {
181- clearTimeout ( timer )
182- timer = setTimeout ( socket . end , idle_timeout * 1000 )
182+ if ( idle_timeout && ! backend . query && queries . length === 0 ) {
183+ clearTimeout ( timer )
184+ timer = setTimeout ( socket . end , idle_timeout * 1000 )
185+ }
183186 }
184187
185188 function onready ( err ) {
@@ -204,7 +207,7 @@ function Connection(options = {}) {
204207 }
205208
206209 backend . query = backend . error = null
207- idle_timeout && queries . length === 0 && idle ( )
210+ idle ( )
208211
209212 if ( ! open ) {
210213 messages . forEach ( socket . write )
@@ -303,6 +306,7 @@ function postgresSocket(options, {
303306 socket . write ( frontend . connect ( options ) )
304307 } catch ( e ) {
305308 error ( e )
309+ socket . end ( )
306310 }
307311 }
308312
You can’t perform that action at this time.
0 commit comments