File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ function Connection(options = {}) {
137
137
: ( messages . push ( buffer ) , connect ( ) )
138
138
} catch ( err ) {
139
139
query . reject ( err )
140
+ idle ( )
140
141
}
141
142
}
142
143
@@ -178,8 +179,10 @@ function Connection(options = {}) {
178
179
}
179
180
180
181
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
+ }
183
186
}
184
187
185
188
function onready ( err ) {
@@ -204,7 +207,7 @@ function Connection(options = {}) {
204
207
}
205
208
206
209
backend . query = backend . error = null
207
- idle_timeout && queries . length === 0 && idle ( )
210
+ idle ( )
208
211
209
212
if ( ! open ) {
210
213
messages . forEach ( socket . write )
@@ -303,6 +306,7 @@ function postgresSocket(options, {
303
306
socket . write ( frontend . connect ( options ) )
304
307
} catch ( e ) {
305
308
error ( e )
309
+ socket . end ( )
306
310
}
307
311
}
308
312
You can’t perform that action at this time.
0 commit comments