i'll fix these ones later

This commit is contained in:
Don Isaac
2025-02-28 20:32:43 -08:00
parent 7ac7f29ebd
commit e69bc7de5b
5 changed files with 1 additions and 125 deletions

View File

@@ -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) {

View File

@@ -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();
}));
}));

View File

@@ -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();

View File

@@ -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);
}));

View File

@@ -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);
})
);
}