diff --git a/src/js/node/net.ts b/src/js/node/net.ts index 4f7dcf8fbf..eed26d678b 100644 --- a/src/js/node/net.ts +++ b/src/js/node/net.ts @@ -923,10 +923,9 @@ const Socket = (function (InternalSocket) { this._writableState.destroyed = true; } - const didDetach = this._handle == null; this._handle = null; callback(err); - if (!didDetach) process.nextTick(emitCloseNT, this, !!err); + process.nextTick(emitCloseNT, this, !!err); } _final(callback) { diff --git a/test/js/node/test/parallel/test-net-socket-destroy-send.js b/test/js/node/test/parallel/test-net-socket-destroy-send.js deleted file mode 100644 index db792ad6d3..0000000000 --- a/test/js/node/test/parallel/test-net-socket-destroy-send.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -const common = require('../common'); -const net = require('net'); -const assert = require('assert'); - -const server = net.createServer(); -server.listen(0, common.mustCall(function() { - const port = server.address().port; - const conn = net.createConnection(port); - - conn.on('connect', common.mustCall(function() { - // Test destroy returns this, even on multiple calls when it short-circuits. - assert.strictEqual(conn, conn.destroy().destroy()); - conn.on('error', common.mustNotCall()); - - conn.write(Buffer.from('kaboom'), common.expectsError({ - code: 'ERR_STREAM_DESTROYED', - message: 'Cannot call write after a stream was destroyed', - name: 'Error' - })); - server.close(); - })); -})); diff --git a/test/js/node/test/parallel/test-net-socket-destroy-twice.js b/test/js/node/test/parallel/test-net-socket-destroy-twice.js deleted file mode 100644 index d33da7c7dc..0000000000 --- a/test/js/node/test/parallel/test-net-socket-destroy-twice.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; -const common = require('../common'); -const net = require('net'); - -const server = net.createServer(); -server.listen(0); -const port = server.address().port; -const conn = net.createConnection(port); - -conn.on('error',common.mustCall(() => { - conn.destroy(); -})); - -conn.on('close', common.mustCall()); -server.close(); diff --git a/test/js/node/test/parallel/test-net-socket-end-callback.js b/test/js/node/test/parallel/test-net-socket-end-callback.js deleted file mode 100644 index a52cee6794..0000000000 --- a/test/js/node/test/parallel/test-net-socket-end-callback.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -const common = require('../common'); -const net = require('net'); - -const server = net.createServer((socket) => { - socket.resume(); -}).unref(); - -server.listen(common.mustCall(() => { - const connect = (...args) => { - const socket = net.createConnection(server.address().port, () => { - socket.end(...args); - }); - }; - - const cb = common.mustCall(3); - - connect(cb); - connect('foo', cb); - connect('foo', 'utf8', cb); -})); diff --git a/test/js/node/test/parallel/test-net-socket-local-address.js b/test/js/node/test/parallel/test-net-socket-local-address.js deleted file mode 100644 index 58645322f4..0000000000 --- a/test/js/node/test/parallel/test-net-socket-local-address.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; -const common = require('../common'); -// Skip test in FreeBSD jails -if (common.inFreeBSDJail) - common.skip('In a FreeBSD jail'); - -const assert = require('assert'); -const net = require('net'); - -let conns = 0; -const clientLocalPorts = []; -const serverRemotePorts = []; -const client = new net.Socket(); -const server = net.createServer((socket) => { - serverRemotePorts.push(socket.remotePort); - socket.end(); -}); - -server.on('close', common.mustCall(() => { - // Client and server should agree on the ports used - assert.deepStrictEqual(serverRemotePorts, clientLocalPorts); - assert.strictEqual(conns, 2); -})); - -server.listen(0, common.localhostIPv4, connect); - -function connect() { - if (conns === 2) { - server.close(); - return; - } - - conns++; - client.once('close', connect); - assert.strictEqual( - client, - client.connect(server.address().port, common.localhostIPv4, () => { - clientLocalPorts.push(client.localPort); - }) - ); -}