Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,11 @@

<!-- YAML
changes:
- version:
- v23.7.0
- v22.14.0
pr-url: https://github.com/nodejs/node/pull/56632

Check warning on line 938 in doc/api/deprecations.md

View workflow job for this annotation

GitHub Actions / lint-pr-url

pr-url doesn't match the URL of the current PR.
description: Application deprecation.
- version: v21.0.0
pr-url: https://github.com/nodejs/node/pull/47202
description: Runtime deprecation.
Expand All @@ -943,7 +948,7 @@
description: Documentation-only deprecation.
-->

Type: Runtime
Type: Application (non-`node_modules` code only)

The [`punycode`][] module is deprecated. Please use a userland alternative
instead.
Expand Down
13 changes: 7 additions & 6 deletions doc/api/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,13 @@ changes:
* `'strip'` Only strip type annotations without performing the transformation of TypeScript features.
* `sourceUrl` {string} Specifies the source url used in the source map.
* Returns: {string} The code with type annotations stripped.
`module.stripTypeScriptTypes()` removes type annotations from TypeScript code. It
can be used to strip type annotations from TypeScript code before running it
with `vm.runInContext()` or `vm.compileFunction()`.
By default, it will throw an error if the code contains TypeScript features
that require transformation such as `Enums`,
see [type-stripping][] for more information.

`module.stripTypeScriptTypes()` removes type annotations from TypeScript code. It
can be used to strip type annotations from TypeScript code before running it
with `vm.runInContext()` or `vm.compileFunction()`.

By default, it will throw an error if the code contains TypeScript features
that require transformation, such as `enum`s. See [type-stripping][] for more information.

_WARNING_: The output of this function should not be considered stable across Node.js versions,
due to changes in the TypeScript parser.
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ function isLoopback(host) {

module.exports = {
kReinitializeHandle: Symbol('kReinitializeHandle'),
kSetNoDelay: Symbol('kSetNoDelay'),
kSetKeepAlive: Symbol('kSetKeepAlive'),
kSetKeepAliveInitialDelay: Symbol('kSetKeepAliveInitialDelay'),
isIP,
isIPv4,
isIPv6,
Expand Down
6 changes: 6 additions & 0 deletions lib/internal/tls/wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@ function TLSSocket(socket, opts) {
highWaterMark: tlsOptions.highWaterMark,
onread: !socket ? tlsOptions.onread : null,
signal: tlsOptions.signal,
noDelay: tlsOptions.noDelay,
keepAlive: tlsOptions.keepAlive,
keepAliveInitialDelay: tlsOptions.keepAliveInitialDelay,
});

// Proxy for API compatibility
Expand Down Expand Up @@ -1755,6 +1758,9 @@ exports.connect = function connect(...args) {
highWaterMark: options.highWaterMark,
onread: options.onread,
signal: options.signal,
noDelay: options.noDelay,
keepAlive: options.keepAlive,
keepAliveInitialDelay: options.keepAliveInitialDelay,
});

// rejectUnauthorized property can be explicitly defined as `undefined`
Expand Down
6 changes: 3 additions & 3 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ let debug = require('internal/util/debuglog').debuglog('net', (fn) => {
});
const {
kReinitializeHandle,
kSetNoDelay,
kSetKeepAlive,
kSetKeepAliveInitialDelay,
isIP,
isIPv4,
isIPv6,
Expand Down Expand Up @@ -356,9 +359,6 @@ function closeSocketHandle(self, isException, isCleanupPending = false) {

const kBytesRead = Symbol('kBytesRead');
const kBytesWritten = Symbol('kBytesWritten');
const kSetNoDelay = Symbol('kSetNoDelay');
const kSetKeepAlive = Symbol('kSetKeepAlive');
const kSetKeepAliveInitialDelay = Symbol('kSetKeepAliveInitialDelay');
const kSetTOS = Symbol('kSetTOS');

function Socket(options) {
Expand Down
65 changes: 65 additions & 0 deletions test/parallel/test-tls-connect-keepalive-nodelay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Flags: --expose-internals
'use strict';

const common = require('../common');

// This test verifies that tls.connect() forwards keepAlive,
// keepAliveInitialDelay, and noDelay options to the underlying socket.

if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const tls = require('tls');
const fixtures = require('../common/fixtures');
const {
kSetNoDelay,
kSetKeepAlive,
kSetKeepAliveInitialDelay,
} = require('internal/net');

const key = fixtures.readKey('agent1-key.pem');
const cert = fixtures.readKey('agent1-cert.pem');

// Test: keepAlive, keepAliveInitialDelay, and noDelay
{
const server = tls.createServer({ key, cert }, (socket) => {
socket.end();
});

server.listen(0, common.mustCall(() => {
const socket = tls.connect({
port: server.address().port,
rejectUnauthorized: false,
keepAlive: true,
keepAliveInitialDelay: 1000,
noDelay: true,
}, common.mustCall(() => {
assert.strictEqual(socket[kSetKeepAlive], true);
assert.strictEqual(socket[kSetKeepAliveInitialDelay], 1);
assert.strictEqual(socket[kSetNoDelay], true);
socket.destroy();
server.close();
}));
}));
}

// Test: defaults (options not set)
{
const server = tls.createServer({ key, cert }, (socket) => {
socket.end();
});

server.listen(0, common.mustCall(() => {
const socket = tls.connect({
port: server.address().port,
rejectUnauthorized: false,
}, common.mustCall(() => {
assert.strictEqual(socket[kSetKeepAlive], false);
assert.strictEqual(socket[kSetKeepAliveInitialDelay], 0);
assert.strictEqual(socket[kSetNoDelay], false);
socket.destroy();
server.close();
}));
}));
}
Loading