Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 5f5201d

Browse files
committed
Fix test-net-connect-buffer
Change to end() behavior in 33c339 was breaking it. end() should wait for connection before dumping. Changed test-net-connect-timeout to use destroy() instead.
1 parent 5f795ef commit 5f5201d

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/net.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,9 +787,7 @@ Socket.prototype._shutdown = function() {
787787

788788

789789
Socket.prototype.end = function(data, encoding) {
790-
if (this._connecting) {
791-
this.destroy();
792-
} else if (this.writable) {
790+
if (this.writable) {
793791
if (this._writeQueueLast() !== END_OF_FILE) {
794792
if (data) this.write(data, encoding);
795793
this._writeQueue.push(END_OF_FILE);

test/simple/test-net-connect-timeout.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ socket0.on('timeout', function() {
3030
gotTimeout0 = true;
3131
var now = new Date();
3232
assert.ok(now - start < T + 500);
33-
socket0.end();
33+
socket0.destroy();
3434
});
3535

3636
socket0.on('connect', function() {
3737
console.error("connect");
3838
gotConnect0 = true;
39-
socket0.end();
39+
socket0.destroy();
4040
});
4141

4242

@@ -51,13 +51,13 @@ socket1.on('timeout', function() {
5151
gotTimeout1 = true;
5252
var now = new Date();
5353
assert.ok(now - start < T + 500);
54-
socket1.end();
54+
socket1.destroy();
5555
});
5656

5757
socket1.on('connect', function() {
5858
console.error("connect");
5959
gotConnect1 = true;
60-
socket1.end();
60+
socket1.destroy();
6161
});
6262

6363

0 commit comments

Comments
 (0)