diff --git a/lib/program.js b/lib/program.js index d7c6d9b..99d4434 100644 --- a/lib/program.js +++ b/lib/program.js @@ -1383,13 +1383,20 @@ Program.prototype.response = function(name, text, callback) { ? 'response ' + name : 'response'; - this.once(name, function(event) { + var onresponse; + + this.once(name, onresponse = function(event) { + if (timeout) clearTimeout(timeout); if (event.type === 'error') { return callback(new Error(event.event + ': ' + event.text)); } return callback(null, event); }); + var timeout = setTimeout(function() { + self.removeListener(name, onresponse); + }, 2000); + return this._write(text); };