diff --git a/lib/core/events.js b/lib/core/events.js index f63e282bf..c10a3125a 100644 --- a/lib/core/events.js +++ b/lib/core/events.js @@ -40,9 +40,12 @@ EventEmitter.prototype.request = function() { EventEmitter.prototype.setCommandHandler = function(requestName, cb) { log("setting command handler for: ", requestName); - return this.on('request:' + requestName, function(_cb) { + let listener = function(_cb) { cb.call(this, ...arguments); - }); + } + // unlike events, commands can only have 1 handler + this.removeAllListeners('request:' + requestName); + return this.on('request:' + requestName, listener); }; EventEmitter.prototype.setCommandHandlerOnce = function(requestName, cb) {