File tree Expand file tree Collapse file tree 1 file changed +5
-13
lines changed
Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -47,27 +47,19 @@ PG.prototype.connect = function(config, callback) {
4747 name : poolName ,
4848 create : function ( callback ) {
4949 var client = new self . Client ( c ) ;
50- client . connect ( ) ;
51-
52- var connectError = function ( err ) {
53- client . removeListener ( 'connect' , connectSuccess ) ;
54- callback ( err , null ) ;
55- } ;
56-
57- var connectSuccess = function ( ) {
58- client . removeListener ( 'error' , connectError ) ;
59-
50+ client . connect ( function ( err ) {
51+ if ( err ) return callback ( err ) ;
52+
6053 //handle connected client background errors by emitting event
6154 //via the pg object and then removing errored client from the pool
6255 client . on ( 'error' , function ( e ) {
6356 self . emit ( 'error' , e , client ) ;
6457 pool . destroy ( client ) ;
6558 } ) ;
59+
6660 callback ( null , client ) ;
67- } ;
61+ } ) ;
6862
69- client . once ( 'connect' , connectSuccess ) ;
70- client . once ( 'error' , connectError ) ;
7163 client . on ( 'drain' , function ( ) {
7264 pool . release ( client ) ;
7365 } ) ;
You can’t perform that action at this time.
0 commit comments