Skip to content

Commit b4f35c2

Browse files
committed
Fix error handling for malformed plain response
1 parent a2be648 commit b4f35c2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/sasl.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var PlainServer = function(callback) {
5757
PlainServer.prototype.start = function(response, hostname) {
5858
var fields = extract(response);
5959
if (fields.length !== 3) {
60-
this.connection.sasl_failed('Unexpected response in PLAIN, got ' + fields.length + ' fields, expected 3');
60+
return Promise.reject('Unexpected response in PLAIN, got ' + fields.length + ' fields, expected 3');
6161
}
6262
var self = this;
6363
return Promise.resolve(this.callback(fields[1], fields[2], hostname))
@@ -208,7 +208,11 @@ SaslServer.prototype.do_fail = function (e) {
208208
var frame = frames.sasl_frame(frames.sasl_outcome({code: sasl_codes.SYS}));
209209
this.transport.encode(frame);
210210
this.connection.output();
211-
this.connection.sasl_failed('Sasl callback promise failed' + e, 'amqp:internal-error');
211+
try {
212+
this.connection.sasl_failed('Sasl callback promise failed with ' + e, 'amqp:internal-error');
213+
} catch (e) {
214+
console.error('Uncaught error: ', e.message);
215+
}
212216
};
213217

214218
SaslServer.prototype.has_writes_pending = function () {

0 commit comments

Comments
 (0)