File tree 2 files changed +17
-5
lines changed
2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -60,13 +60,14 @@ Pool.prototype.connect = function (cb) {
60
60
this . log ( 'acquire client' )
61
61
62
62
client . release = function ( err ) {
63
+ delete client . release
63
64
if ( err ) {
64
- this . log ( 'release client. error:' , err )
65
+ this . log ( 'destroy client. error:' , err )
65
66
this . pool . destroy ( client )
67
+ } else {
68
+ this . log ( 'release client' )
69
+ this . pool . release ( client )
66
70
}
67
- this . log ( 'release client' )
68
- delete client . release
69
- this . pool . release ( client )
70
71
} . bind ( this )
71
72
72
73
if ( cb ) {
Original file line number Diff line number Diff line change @@ -89,7 +89,18 @@ describe('pool', function () {
89
89
} ) )
90
90
91
91
it ( 'recovers from all errors' , co . wrap ( function * ( ) {
92
- var pool = new Pool ( { poolSize : 9 } )
92
+ var pool = new Pool ( {
93
+ poolSize : 9 ,
94
+ log : function ( str , level ) {
95
+ // Custom logging function to ensure we are not causing errors or warnings
96
+ // inside the `generic-pool` library.
97
+ if ( level === 'error' || level === 'warn' ) {
98
+ expect ( ) . fail ( 'An error or warning was logged from the generic pool library.\n' +
99
+ 'Level: ' + level + '\n' +
100
+ 'Message: ' + str + '\n' )
101
+ }
102
+ }
103
+ } )
93
104
var count = 0
94
105
95
106
while ( count ++ < 30 ) {
You can’t perform that action at this time.
0 commit comments