Skip to content

Commit d40ffc8

Browse files
committed
always emit end when command is complete; release connection to pool on end. Fixes #569
1 parent 73fcf54 commit d40ffc8

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

lib/commands/command.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ Command.prototype.execute = function(packet, connection) {
2828
var err = packet.asError(connection.clientEncoding);
2929
if (this.onResult) {
3030
this.onResult(err);
31+
this.emit('end');
3132
} else {
3233
this.emit('error', err);
34+
this.emit('end');
3335
}
3436
return true;
3537
}

lib/connection.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ Connection.prototype.execute = function execute(sql, values, cb) {
714714
} else {
715715
executeCommand.emit('error', err);
716716
}
717+
executeCommand.emit('end');
717718
return;
718719
}
719720

lib/pool.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,9 @@ Pool.prototype.execute = function(sql, values, cb) {
170170
return cb(err);
171171
}
172172

173-
conn.config.namedPlaceholders = useNamedPlaceholders;
174-
return conn.execute(sql, values, function() {
173+
const executeCmd = conn.execute(sql, values, cb);
174+
executeCmd.once('end', function() {
175175
conn.release();
176-
cb.apply(this, arguments);
177176
});
178177
});
179178
};

0 commit comments

Comments
 (0)