There was an error while loading. Please reload this page.
connect
finish
destroySoon
1 parent fb34515 commit 6e33069Copy full SHA for 6e33069
1 file changed
lib/net.js
@@ -529,8 +529,9 @@ Socket.prototype._unrefTimer = function _unrefTimer() {
529
// sent out to the other side.
530
Socket.prototype._final = function(cb) {
531
// If still connecting - defer handling `_final` until 'connect' will happen
532
- if (this.connecting) {
+ if (this.connecting && !this._finalizingOnConnect) {
533
debug('_final: not yet connected');
534
+ this._finalizingOnConnect = true;
535
return this.once('connect', () => this._final(cb));
536
}
537
@@ -800,8 +801,10 @@ Socket.prototype.destroySoon = function() {
800
801
802
if (this.writableFinished)
803
this.destroy();
- else
804
+ else if (!this._destroyingOnFinish) {
805
+ this._destroyingOnFinish = true;
806
this.once('finish', this.destroy);
807
+ }
808
};
809
810
0 commit comments