mirror of
https://github.com/eleith/emailjs.git
synced 2024-07-05 20:10:37 +00:00
bugfix issue #113: callback called multiple times with error
response listener was called twice when the socket is already closed
and the state is not connected.
revert changes in commit 23832df015
This commit is contained in:
parent
9926a9f34e
commit
232c63798b
@ -35,12 +35,6 @@ Client.prototype =
|
||||
self.timer = setTimeout(function() { self.smtp.quit(); }, 1000);
|
||||
},
|
||||
|
||||
_isMessageInQueue: function(messageId) {
|
||||
return this.queue.some(function(item) {
|
||||
return item.message.header['message-id'] === messageId;
|
||||
});
|
||||
},
|
||||
|
||||
_connect: function(stack)
|
||||
{
|
||||
var self = this,
|
||||
@ -72,9 +66,7 @@ Client.prototype =
|
||||
self.smtp.ehlo_or_helo_if_needed(begin);
|
||||
}
|
||||
else {
|
||||
if (self._isMessageInQueue(stack.message.header['message-id'])) {
|
||||
stack.callback(err, stack.message);
|
||||
}
|
||||
stack.callback(err, stack.message);
|
||||
|
||||
// clear out the queue so all callbacks can be called with the same error message
|
||||
self.queue.shift();
|
||||
|
@ -131,6 +131,9 @@ SMTP.prototype = {
|
||||
|
||||
var response = function(err, msg) {
|
||||
if (err) {
|
||||
if (self._state === SMTPState.NOTCONNECTED && !self.sock) {
|
||||
return;
|
||||
}
|
||||
self.close(true);
|
||||
caller(callback, err);
|
||||
} else if (msg.code == '220') {
|
||||
|
Loading…
Reference in New Issue
Block a user