Skip to content

Commit 0c258b5

Browse files
committed
v8.9.0
1 parent 98eaf90 commit 0c258b5

37 files changed

+377
-0
lines changed

cli/force_async_hooks_checks.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!-- YAML
2+
added: v8.8.0
3+
-->
4+
5+
Enables runtime checks for `async_hooks`. These can also be enabled dynamically
6+
by enabling one of the `async_hooks` hooks.
7+

cli/node_no_http2_1.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- YAML
2+
added: v8.8.0
3+
-->
4+
5+
When set to `1`, the `http2` module is suppressed.
6+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- YAML
2+
added: v1.1.0
3+
-->
4+
- `key` {Object | string}
5+
- `key` {string} A PEM encoded public or private key.
6+
- `passphrase` {string} An optional passphrase for the private key.
7+
- `padding` {crypto.constants} An optional padding value defined in
8+
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or
9+
`RSA_PKCS1_PADDING`.
10+
- `buffer` {Buffer | TypedArray | DataView}
11+
- Returns: {Buffer} A new `Buffer` with the decrypted content.
12+
13+
Decrypts `buffer` with `key`.
14+
15+
`key` can be an object or a string. If `key` is a string, it is treated as
16+
the key with no passphrase and will use `RSA_PKCS1_PADDING`.
17+
18+
Because RSA public keys can be derived from private keys, a private key may
19+
be passed instead of a public key.
20+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- YAML
2+
added: v0.11.14
3+
-->
4+
- `key` {Object | string}
5+
- `key` {string} A PEM encoded public or private key.
6+
- `passphrase` {string} An optional passphrase for the private key.
7+
- `padding` {crypto.constants} An optional padding value defined in
8+
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
9+
`RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`.
10+
- `buffer` {Buffer | TypedArray | DataView}
11+
- Returns: {Buffer} A new `Buffer` with the encrypted content.
12+
13+
Encrypts the content of `buffer` with `key` and returns a new
14+
[`Buffer`][] with encrypted content.
15+
16+
`key` can be an object or a string. If `key` is a string, it is treated as
17+
the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.
18+
19+
Because RSA public keys can be derived from private keys, a private key may
20+
be passed instead of a public key.
21+

dgram/socket_getrecvbuffersize.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- YAML
2+
added: v8.7.0
3+
-->
4+
5+
* Returns {number} the `SO_RCVBUF` socket receive buffer size in bytes.
6+

dgram/socket_getsendbuffersize.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- YAML
2+
added: v8.7.0
3+
-->
4+
5+
* Returns {number} the `SO_SNDBUF` socket send buffer size in bytes.
6+

errors/err_async_callback.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used with `AsyncHooks` to indicate an attempt of registering something that is
3+
not a function as a callback.
4+
5+
<a id="ERR_ASYNC_TYPE"></a>

errors/err_async_type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used when the type of an asynchronous resource is invalid. Note that users are
3+
also able to define their own types when using the public embedder API.
4+
5+
<a id="ERR_ENCODING_INVALID_ENCODED_DATA"></a>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used by the `util.TextDecoder()` API when the data provided is invalid
3+
according to the encoding provided.
4+
5+
<a id="ERR_ENCODING_NOT_SUPPORTED"></a>

errors/err_encoding_not_supported.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used by the `util.TextDecoder()` API when the encoding provided is not one of
3+
the [WHATWG Supported Encodings][].
4+
5+
<a id="ERR_FALSY_VALUE_REJECTION"></a>

errors/err_http2_header_required.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
Used when a required header is missing in an HTTP/2 message.
3+
4+
<a id="ERR_HTTP2_HEADER_SINGLE_VALUE"></a>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used when trying to specify additional headers after an HTTP/2 response
3+
initiated.
4+
5+
<a id="ERR_HTTP2_HEADERS_OBJECT"></a>

errors/err_http_invalid_char.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used when an invalid character is found in an HTTP response status message
3+
(reason phrase).
4+
5+
<a id="ERR_HTTP_INVALID_STATUS_CODE"></a>

errors/err_invalid_async_id.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used with `AsyncHooks` when an invalid `asyncId` or `triggerAsyncId` is passed.
3+
An id less than -1 should never happen.
4+
5+
<a id="ERR_INVALID_CALLBACK"></a>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used by the Performance Timing API (`perf_hooks`) when a performance mark is
3+
invalid.
4+
5+
<a id="ERR_INVALID_PROTOCOL"></a>

errors/err_napi_cons_function.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
Used by the `N-API` when a constructor passed is not a function.
3+
4+
<a id="ERR_NAPI_CONS_PROTOTYPE_OBJECT"></a>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
Used by the `N-API` when `Constructor.prototype` is not an object.
3+
4+
<a id="ERR_NO_ICU"></a>

errors/err_outofmemory.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used generically to identify that an operation caused an out of memory
3+
condition.
4+
5+
<a id="ERR_SOCKET_ALREADY_BOUND"></a>

errors/err_socket_closed.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
Used when an attempt is made to operate on an already closed socket.
3+
4+
<a id="ERR_SOCKET_DGRAM_NOT_RUNNING"></a>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used with TLS, when the hostname/IP of the peer does not match any of the
3+
subjectAltNames in its certificate.
4+
5+
<a id="ERR_TLS_DH_PARAM_SIZE"></a>

errors/err_tls_dh_param_size.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
Used with TLS when the parameter offered for the Diffie-Hellman (`DH`)
3+
key-agreement protocol is too small. By default, the key length must be greater
4+
than or equal to 1024 bits to avoid vulnerabilities, even though it is strongly
5+
recommended to use 2048 bits or larger for stronger security.
6+
7+
<a id="ERR_TLS_HANDSHAKE_TIMEOUT"></a>

errors/err_tls_handshake_timeout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
A TLS error emitted by the server whenever a TLS/SSL handshake times out. In
3+
this case, the server must also abort the connection.
4+
5+
<a id="ERR_TLS_RENEGOTIATION_FAILED"></a>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
Used when a TLS renegotiation request has failed in a non-specific way.
3+
4+
<a id="ERR_TLS_REQUIRED_SERVER_NAME"></a>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used with TLS, when calling the `server.addContext()` method without providing
3+
a hostname in the first parameter.
4+
5+
<a id="ERR_TLS_SESSION_ATTACK"></a>

errors/err_tls_session_attack.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used when an excessive amount of TLS renegotiations is detected, which is a
3+
potential vector for denial-of-service attacks.
4+
5+
<a id="ERR_TRANSFORM_ALREADY_TRANSFORMING"></a>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used in Transform streams when the stream finishes while it is still
3+
transforming.
4+
5+
<a id="ERR_TRANSFORM_WITH_LENGTH_0"></a>

errors/err_transform_with_length_0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Used in Transform streams when the stream finishes with data still in the write
3+
buffer.
4+
5+
<a id="ERR_UNKNOWN_SIGNAL"></a>

esm/dynamic_instantiate_hook.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
To create a custom dynamic module that doesn't correspond to one of the
3+
existing `format` interpretations, the `dynamicInstantiate` hook can be used.
4+
This hook is called only for modules that return `format: "dynamic"` from
5+
the `resolve` hook.
6+
7+
```js
8+
export async function dynamicInstantiate(url) {
9+
return {
10+
exports: ['customExportName'],
11+
execute: (exports) => {
12+
// get and set functions provided for pre-allocated export names
13+
exports.customExportName.set('value');
14+
}
15+
};
16+
}
17+
```
18+
19+
With the list of module exports provided upfront, the `execute` function will
20+
then be called at the exact point of module evalutation order for that module
21+
in the import tree.
22+
23+
[Node.js EP for ES Modules]: https://github.com/nodejs/node-eps/blob/master/002-es-modules.md

esm/loader_hooks.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
<!-- type=misc -->
3+
4+
To customize the default module resolution, loader hooks can optionally be
5+
provided via a `--loader ./loader-name.mjs` argument to Node.
6+
7+
When hooks are used they only apply to ES module loading and not to any
8+
CommonJS modules loaded.
9+

esm/resolve_hook.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
The resolve hook returns the resolved file URL and module format for a
3+
given module specifier and parent file URL:
4+
5+
```js
6+
import url from 'url';
7+
8+
export async function resolve(specifier, parentModuleURL, defaultResolver) {
9+
return {
10+
url: new URL(specifier, parentModuleURL).href,
11+
format: 'esm'
12+
};
13+
}
14+
```
15+
16+
The default NodeJS ES module resolution function is provided as a third
17+
argument to the resolver for easy compatibility workflows.
18+
19+
In addition to returning the resolved file URL value, the resolve hook also
20+
returns a `format` property specifying the module format of the resolved
21+
module. This can be one of `"esm"`, `"cjs"`, `"json"`, `"builtin"` or
22+
`"addon"`.
23+
24+
For example a dummy loader to load JavaScript restricted to browser resolution
25+
rules with only JS file extension and Node builtin modules support could
26+
be written:
27+
28+
```js
29+
import url from 'url';
30+
import path from 'path';
31+
import process from 'process';
32+
33+
const builtins = new Set(
34+
Object.keys(process.binding('natives')).filter((str) =>
35+
/^(?!(?:internal|node|v8)\/)/.test(str))
36+
);
37+
const JS_EXTENSIONS = new Set(['.js', '.mjs']);
38+
39+
export function resolve(specifier, parentModuleURL/*, defaultResolve */) {
40+
if (builtins.has(specifier)) {
41+
return {
42+
url: specifier,
43+
format: 'builtin'
44+
};
45+
}
46+
if (/^\.{0,2}[/]/.test(specifier) !== true && !specifier.startsWith('file:')) {
47+
// For node_modules support:
48+
// return defaultResolve(specifier, parentModuleURL);
49+
throw new Error(
50+
`imports must begin with '/', './', or '../'; '${specifier}' does not`);
51+
}
52+
const resolved = new url.URL(specifier, parentModuleURL);
53+
const ext = path.extname(resolved.pathname);
54+
if (!JS_EXTENSIONS.has(ext)) {
55+
throw new Error(
56+
`Cannot load file with non-JavaScript file extension ${ext}.`);
57+
}
58+
return {
59+
url: resolved.href,
60+
format: 'esm'
61+
};
62+
}
63+
```
64+
65+
With this loader, running:
66+
67+
```console
68+
NODE_OPTIONS='--experimental-modules --loader ./custom-loader.mjs' node x.js
69+
```
70+
71+
would load the module `x.js` as an ES module with relative resolution support
72+
(with `node_modules` loading skipped in this example).
73+

http/server_listen.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
Starts the HTTP server listening for connections.
3+
This method is identical to [`server.listen()`][] from [`net.Server`][].
4+

http2/client_side_example.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
The following illustrates an HTTP/2 client:
3+
4+
```js
5+
const http2 = require('http2');
6+
const fs = require('fs');
7+
const client = http2.connect('https://localhost:8443', {
8+
ca: fs.readFileSync('localhost-cert.pem')
9+
});
10+
client.on('socketError', (err) => console.error(err));
11+
client.on('error', (err) => console.error(err));
12+
13+
const req = client.request({ ':path': '/' });
14+
15+
req.on('response', (headers, flags) => {
16+
for (const name in headers) {
17+
console.log(`${name}: ${headers[name]}`);
18+
}
19+
});
20+
21+
req.setEncoding('utf8');
22+
let data = '';
23+
req.on('data', (chunk) => { data += chunk; });
24+
req.on('end', () => {
25+
console.log(`\n${data}`);
26+
client.destroy();
27+
});
28+
req.end();
29+
```
30+

http2/server_side_example.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
The following illustrates a simple, plain-text HTTP/2 server using the
3+
Core API:
4+
5+
```js
6+
const http2 = require('http2');
7+
const fs = require('fs');
8+
9+
const server = http2.createSecureServer({
10+
key: fs.readFileSync('localhost-privkey.pem'),
11+
cert: fs.readFileSync('localhost-cert.pem')
12+
});
13+
server.on('error', (err) => console.error(err));
14+
server.on('socketError', (err) => console.error(err));
15+
16+
server.on('stream', (stream, headers) => {
17+
// stream is a Duplex
18+
stream.respond({
19+
'content-type': 'text/html',
20+
':status': 200
21+
});
22+
stream.end('<h1>Hello World</h1>');
23+
});
24+
25+
server.listen(8443);
26+
```
27+
28+
To generate the certificate and key for this example, run:
29+
30+
```bash
31+
openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' \
32+
-keyout localhost-privkey.pem -out localhost-cert.pem
33+
```
34+

https/server_listen.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
Starts the HTTPS server listening for encrypted connections.
3+
This method is identical to [`server.listen()`][] from [`net.Server`][].
4+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!-- YAML
2+
added: v8.9.0
3+
-->
4+
5+
* `request` {string} The module path whose lookup paths are being retrieved.
6+
* Returns: {Array}
7+
8+
Returns an array containing the paths searched during resolution of `request`.
9+

0 commit comments

Comments
 (0)