stream: use `errorEmitted` from `_writableState`
This commit is contained in:
Родитель
c0d81f9099
Коммит
e2a1d9a9ac
|
@ -117,7 +117,7 @@ function WritableState(options, stream) {
|
|||
this.prefinished = false;
|
||||
|
||||
// Internal, used in net.js and _tls_wrap.js
|
||||
this._errorEmitted = false;
|
||||
this.errorEmitted = false;
|
||||
}
|
||||
|
||||
function Writable(options) {
|
||||
|
@ -274,8 +274,8 @@ function onwriteError(stream, state, sync, er, cb) {
|
|||
cb(er);
|
||||
}
|
||||
|
||||
stream._writableState.errorEmitted = true;
|
||||
stream.emit('error', er);
|
||||
stream._errorEmitted = true;
|
||||
}
|
||||
|
||||
function onwriteStateUpdate(state) {
|
||||
|
|
|
@ -238,9 +238,9 @@ TLSSocket.prototype._init = function(socket) {
|
|||
}
|
||||
|
||||
this.ssl.onerror = function(err) {
|
||||
if (self._errorEmitted)
|
||||
if (self._writableState.errorEmitted)
|
||||
return;
|
||||
self._errorEmitted = true;
|
||||
self._writableState.errorEmitted = true;
|
||||
|
||||
// Destroy socket if error happened before handshake's finish
|
||||
if (!this._secureEstablished) {
|
||||
|
|
|
@ -428,11 +428,11 @@ Socket.prototype._destroy = function(exception, cb) {
|
|||
|
||||
function fireErrorCallbacks() {
|
||||
if (cb) cb(exception);
|
||||
if (exception && !self._errorEmitted) {
|
||||
if (exception && !self._writableState.errorEmitted) {
|
||||
process.nextTick(function() {
|
||||
self.emit('error', exception);
|
||||
});
|
||||
self._errorEmitted = true;
|
||||
self._writableState.errorEmitted = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче