mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
net: only defer _final call when connecting
Fixes: https://github.com/nodejs/node/issues/47322 PR-URL: https://github.com/nodejs/node/pull/47385 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
This commit is contained in:
@@ -508,7 +508,7 @@ Socket.prototype._unrefTimer = function _unrefTimer() {
|
||||
// sent out to the other side.
|
||||
Socket.prototype._final = function(cb) {
|
||||
// If still connecting - defer handling `_final` until 'connect' will happen
|
||||
if (this.pending) {
|
||||
if (this.connecting) {
|
||||
debug('_final: not yet connected');
|
||||
return this.once('connect', () => this._final(cb));
|
||||
}
|
||||
|
||||
@@ -20,8 +20,11 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
const common = require('../common');
|
||||
const net = require('net');
|
||||
const assert = require('assert');
|
||||
|
||||
const sock = new net.Socket();
|
||||
sock.end(); // Should not throw.
|
||||
sock.end(common.mustCall(() => {
|
||||
assert.strictEqual(sock.writable, false);
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user