File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ Pool.prototype._create = function (cb) {
90
90
this . log ( 'connected client error:' , e )
91
91
this . pool . destroy ( client )
92
92
e . client = client
93
- this . emit ( 'error' , e )
93
+ this . emit ( 'error' , e , client )
94
94
} . bind ( this ) )
95
95
96
96
client . connect ( function ( err ) {
Original file line number Diff line number Diff line change @@ -60,6 +60,22 @@ describe('events', function () {
60
60
pool . end ( done )
61
61
} , 40 )
62
62
} )
63
+
64
+ it ( 'emits error and client if an idle client in the pool hits an error' , function ( done ) {
65
+ var pool = new Pool ( )
66
+ pool . connect ( function ( err , client ) {
67
+ expect ( err ) . to . equal ( null )
68
+ client . release ( )
69
+ setImmediate ( function ( ) {
70
+ client . emit ( 'error' , new Error ( 'problem' ) )
71
+ } )
72
+ pool . once ( 'error' , function ( err , errClient ) {
73
+ expect ( err . message ) . to . equal ( 'problem' )
74
+ expect ( errClient ) . to . equal ( client )
75
+ done ( )
76
+ } )
77
+ } )
78
+ } )
63
79
} )
64
80
65
81
function mockClient ( methods ) {
You can’t perform that action at this time.
0 commit comments