Skip to content

Commit

Permalink
test: remove timers from test-tls-socket-close
Browse files Browse the repository at this point in the history
Fixes: #49902
  • Loading branch information
lpinca committed May 16, 2024
1 parent 6a2d6df commit 5581681
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions test/parallel/test-tls-socket-close.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const cert = fixtures.readKey('agent2-cert.pem');
let serverTlsSocket;
const tlsServer = tls.createServer({ cert, key }, (socket) => {
serverTlsSocket = socket;
socket.on('data', (chunk) => {
assert.strictEqual(chunk[0], 46);
socket.write('.');
});
socket.on('close', dec);
});

Expand Down Expand Up @@ -45,24 +49,23 @@ function connectClient(server) {
rejectUnauthorized: false
});

clientTlsSocket.write('foo', 'utf8', common.mustCall(() => {
assert(netSocket);
netSocket.setTimeout(common.platformTimeout(10), common.mustCall(() => {
assert(serverTlsSocket);
clientTlsSocket.write('.');

clientTlsSocket.on('data', (chunk) => {
assert.strictEqual(chunk[0], 46);

netSocket.destroy();
assert.strictEqual(netSocket.destroyed, true);
netSocket.destroy();
assert.strictEqual(netSocket.destroyed, true);

setImmediate(() => {
// Close callbacks are executed after `setImmediate()` callbacks.
assert.strictEqual(netSocketCloseEmitted, false);
assert.strictEqual(serverTlsSocket.destroyed, false);
setImmediate(() => {
// Close callbacks are executed after `setImmediate()` callbacks.
assert.strictEqual(netSocketCloseEmitted, false);
assert.strictEqual(serverTlsSocket.destroyed, false);
setImmediate(() => {
assert.strictEqual(netSocketCloseEmitted, true);
});
assert.strictEqual(netSocketCloseEmitted, true);
});
}));
}));
});
});

clientTlsSocket.on('close', dec);
}
Expand Down

0 comments on commit 5581681

Please sign in to comment.