mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
7534477786
PR-URL: https://github.com/nodejs/node/pull/32542 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
// Flags: --expose-internals
|
|
|
|
'use strict';
|
|
const common = require('../common');
|
|
const { kTimeout, TIMEOUT_MAX } = require('internal/timers');
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const tls = require('tls');
|
|
const net = require('net');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const options = {
|
|
key: fixtures.readKey('agent1-key.pem'),
|
|
cert: fixtures.readKey('agent1-cert.pem')
|
|
};
|
|
|
|
const server = tls.createServer(options, common.mustCall((c) => {
|
|
setImmediate(() => {
|
|
c.write('hello', () => {
|
|
setImmediate(() => {
|
|
c.destroy();
|
|
server.close();
|
|
});
|
|
});
|
|
});
|
|
}));
|
|
|
|
let socket;
|
|
let lastIdleStart;
|
|
|
|
server.listen(0, () => {
|
|
socket = net.connect(server.address().port, function() {
|
|
const s = socket.setTimeout(TIMEOUT_MAX, function() {
|
|
throw new Error('timeout');
|
|
});
|
|
assert.ok(s instanceof net.Socket);
|
|
|
|
assert.notStrictEqual(socket[kTimeout]._idleTimeout, -1);
|
|
lastIdleStart = socket[kTimeout]._idleStart;
|
|
|
|
const tsocket = tls.connect({
|
|
socket: socket,
|
|
rejectUnauthorized: false
|
|
});
|
|
tsocket.resume();
|
|
});
|
|
});
|
|
|
|
process.on('exit', () => {
|
|
assert.strictEqual(socket[kTimeout]._idleTimeout, -1);
|
|
assert(lastIdleStart < socket[kTimeout]._idleStart);
|
|
});
|