mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08: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:
1 parent
9398ff1dea
commit
c15bafdaf4
2 files changed
+6
-3
No files matched your search
+1
-1
@@ -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