@@ -38,7 +38,7 @@ function Connection(options = {}) {
38
38
, connection = { send, end, destroy }
39
39
40
40
const socket = postgresSocket ( options , {
41
- ready : ( ) => socket . write ( frontend . connect ( options ) ) ,
41
+ ready,
42
42
data,
43
43
error,
44
44
close
@@ -114,26 +114,26 @@ function Connection(options = {}) {
114
114
}
115
115
116
116
function send ( query , { sig, str, args = [ ] } ) {
117
- query . str = str
118
- query . args = args
119
- query . result = [ ]
120
- query . result . count = null
121
- idle_timeout && clearTimeout ( timer )
122
-
123
- typeof options . debug === 'function' && options . debug ( id , str , args )
124
- const buffer = query . simple
125
- ? simple ( str , query )
126
- : sig in statements
127
- ? prepared ( statements [ sig ] , args , query )
128
- : prepare ( sig , str , args , query )
129
-
130
- ready
131
- ? ( backend . query = query , ready = false )
132
- : queries . push ( query )
133
-
134
- open
135
- ? socket . write ( buffer )
136
- : ( messages . push ( buffer ) , connect ( ) )
117
+ query . str = str
118
+ query . args = args
119
+ query . result = [ ]
120
+ query . result . count = null
121
+ idle_timeout && clearTimeout ( timer )
122
+
123
+ typeof options . debug === 'function' && options . debug ( id , str , args )
124
+ const buffer = query . simple
125
+ ? simple ( str , query )
126
+ : sig in statements
127
+ ? prepared ( statements [ sig ] , args , query )
128
+ : prepare ( sig , str , args , query )
129
+
130
+ ready
131
+ ? ( backend . query = query , ready = false )
132
+ : queries . push ( query )
133
+
134
+ open
135
+ ? socket . write ( buffer )
136
+ : ( messages . push ( buffer ) , connect ( ) )
137
137
}
138
138
139
139
function connect ( ) {
@@ -244,7 +244,6 @@ function Connection(options = {}) {
244
244
function postgresSocket ( options , {
245
245
error,
246
246
close,
247
- ready,
248
247
data
249
248
} ) {
250
249
let socket
@@ -295,6 +294,14 @@ function postgresSocket(options, {
295
294
socket . once ( 'close' , onclose )
296
295
}
297
296
297
+ function ready ( ) {
298
+ try {
299
+ socket . write ( frontend . connect ( options ) )
300
+ } catch ( e ) {
301
+ error ( e )
302
+ }
303
+ }
304
+
298
305
const x = {
299
306
write : x => {
300
307
buffer = buffer ? Buffer . concat ( [ buffer , x ] ) : Buffer . from ( x )
0 commit comments