diff --git a/lib/sender.js b/lib/sender.js index e4888cb..b75385b 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -104,7 +104,8 @@ class FluentSender { } this._push(tag, timestamp, data, callback); - this._connect(() => { + this._connect((error) => { + error && callback && callback(error); this._flushSendQueue(); }); } @@ -206,9 +207,9 @@ class FluentSender { this._connecting = true; process.nextTick(() => { if (this._socket === null) { - this._doConnect(() => { + this._doConnect((error) => { this._connecting = false; - callback(); + callback(error); }); } else { if (!this._socket.writable) { @@ -232,7 +233,7 @@ class FluentSender { let errorHandler = (err) => { if (this._socket) { this._disconnect(); - this._handleEvent('error', err); + this._handleEvent('error', err, callback); } }; this._socket.on('error', errorHandler);