Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c15bafd

Browse filesBrowse files
authored
net: only defer _final call when connecting
Fixes: #47322 PR-URL: #47385 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
1 parent 9398ff1 commit c15bafd
Copy full SHA for c15bafd

File tree

Expand file treeCollapse file tree

2 files changed

+6
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-3
lines changed
Open diff view settings
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ Socket.prototype._unrefTimer = function _unrefTimer() {
508508
// sent out to the other side.
509509
Socket.prototype._final = function(cb) {
510510
// If still connecting - defer handling `_final` until 'connect' will happen
511-
if (this.pending) {
511+
if (this.connecting) {
512512
debug('_final: not yet connected');
513513
return this.once('connect', () => this._final(cb));
514514
}
Collapse file

‎test/parallel/test-net-end-without-connect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-net-end-without-connect.js
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
require('../common');
23+
const common = require('../common');
2424
const net = require('net');
25+
const assert = require('assert');
2526

2627
const sock = new net.Socket();
27-
sock.end(); // Should not throw.
28+
sock.end(common.mustCall(() => {
29+
assert.strictEqual(sock.writable, false);
30+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.