|
57 | 57 |
|
58 | 58 | ### Notable changes |
59 | 59 |
|
60 | | -TODO |
| 60 | +#### Semver-minor changes |
| 61 | + |
| 62 | +##### Advanced serialization for IPC |
| 63 | + |
| 64 | +The `child_process` and `cluster` modules now support a `serialization` option |
| 65 | +to change the serialization mechanism used for IPC. The option can have one of |
| 66 | +two values: |
| 67 | + |
| 68 | +* `'json'` (default): `JSON.stringify()` and `JSON.parse()` are used. This is |
| 69 | + how message serialization was done before. |
| 70 | +* `'advanced'`: The serialization API of the `v8` module is used. It is based on |
| 71 | + the [HTML structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm) |
| 72 | + and is able to serialize more built-in JavaScript object types, such as |
| 73 | + `BigInt`, `Map`, `Set` etc. as well as circular data structures. |
| 74 | + |
| 75 | +Anna Henningsen [#30162](https://github.com/nodejs/node/pull/30162). |
| 76 | + |
| 77 | +##### CLI flags |
| 78 | + |
| 79 | +The new `--trace-exit` CLI flag makes Node.js print a stack trace whenever the |
| 80 | +Node.js environment is exited proactively (i.e. by invoking the `process.exit()` |
| 81 | +function or pressing Ctrl+C). |
| 82 | + |
| 83 | +legendecas [#30516](https://github.com/nodejs/node/pull/30516). |
| 84 | + |
| 85 | +___ |
| 86 | + |
| 87 | +The new `--trace-uncaught` CLI flag makes Node.js print a stack trace at the |
| 88 | +time of throwing uncaught exceptions, rather than at the creation of the `Error` |
| 89 | +object, if there is any. |
| 90 | +This option is not enabled by default because it may affect garbage collection |
| 91 | +behavior negatively. |
| 92 | + |
| 93 | +Anna Henningsen [#30025](https://github.com/nodejs/node/pull/30025). |
| 94 | + |
| 95 | +___ |
| 96 | + |
| 97 | +The `--disallow-code-generation-from-strings` V8 CLI flag is now whitelisted in |
| 98 | +the `NODE_OPTIONS` environment variable. |
| 99 | + |
| 100 | +Shelley Vohr [#30094](https://github.com/nodejs/node/pull/30094). |
| 101 | + |
| 102 | +##### New crypto APIs |
| 103 | + |
| 104 | +For DSA and ECDSA, a new signature encoding is now supported in addition to the |
| 105 | +existing one (DER). The `verify` and `sign` methods accept a `dsaEncoding` |
| 106 | +option, which can have one of two values: |
| 107 | + |
| 108 | +* `'der'` (default): DER-encoded ASN.1 signature structure encoding `(r, s)`. |
| 109 | +* `'ieee-p1363'`: Signature format `r || s` as proposed in IEEE-P1363. |
| 110 | + |
| 111 | +Tobias Nießen [#29292](https://github.com/nodejs/node/pull/29292). |
| 112 | + |
| 113 | +___ |
| 114 | + |
| 115 | +A new method was added to `Hash`: `Hash.prototype.copy`. It makes it possible to |
| 116 | +clone the internal state of a `Hash` object into a new `Hash` object, allowing |
| 117 | +to compute the digest between updates: |
| 118 | + |
| 119 | +```js |
| 120 | +// Calculate a rolling hash. |
| 121 | +const crypto = require('crypto'); |
| 122 | +const hash = crypto.createHash('sha256'); |
| 123 | + |
| 124 | +hash.update('one'); |
| 125 | +console.log(hash.copy().digest('hex')); |
| 126 | + |
| 127 | +hash.update('two'); |
| 128 | +console.log(hash.copy().digest('hex')); |
| 129 | + |
| 130 | +hash.update('three'); |
| 131 | +console.log(hash.copy().digest('hex')); |
| 132 | + |
| 133 | +// Etc. |
| 134 | +``` |
| 135 | + |
| 136 | +Ben Noordhuis [#29910](https://github.com/nodejs/node/pull/29910). |
| 137 | + |
| 138 | +##### Dependency updates |
| 139 | + |
| 140 | +libuv was updated to 1.34.0. This includes fixes to `uv_fs_copyfile()` and |
| 141 | +`uv_interface_addresses()` and adds two new functions: `uv_sleep()` and |
| 142 | +`uv_fs_mkstemp()`. |
| 143 | + |
| 144 | +Colin Ihrig [#30783](https://github.com/nodejs/node/pull/30783). |
| 145 | + |
| 146 | +___ |
| 147 | + |
| 148 | +V8 was updated to 7.8.279.23. This includes performance improvements to object |
| 149 | +destructuring, RegExp match failures and WebAssembly startup time. |
| 150 | +The official release notes are available at https://v8.dev/blog/v8-release-78. |
| 151 | + |
| 152 | +Michaël Zasso [#30109](https://github.com/nodejs/node/pull/30109). |
| 153 | + |
| 154 | +##### New EventEmitter APIs |
| 155 | + |
| 156 | +The new `EventEmitter.on` static method allows to async iterate over events: |
| 157 | + |
| 158 | +```js |
| 159 | +const { on, EventEmitter } = require('events'); |
| 160 | + |
| 161 | +(async () => { |
| 162 | + |
| 163 | + const ee = new EventEmitter(); |
| 164 | + |
| 165 | + // Emit later on |
| 166 | + process.nextTick(() => { |
| 167 | + ee.emit('foo', 'bar'); |
| 168 | + ee.emit('foo', 42); |
| 169 | + }); |
| 170 | + |
| 171 | + for await (const event of on(ee, 'foo')) { |
| 172 | + // The execution of this inner block is synchronous and it |
| 173 | + // processes one event at a time (even with await). Do not use |
| 174 | + // if concurrent execution is required. |
| 175 | + console.log(event); // prints ['bar'] [42] |
| 176 | + } |
| 177 | + |
| 178 | +})(); |
| 179 | +``` |
| 180 | + |
| 181 | +Matteo Collina [#27994](https://github.com/nodejs/node/pull/27994). |
| 182 | + |
| 183 | +___ |
| 184 | + |
| 185 | +It is now possible to monitor `'error'` events on an `EventEmitter` without |
| 186 | +consuming the emitted error by installing a listener using the symbol |
| 187 | +`EventEmitter.errorMonitor`: |
| 188 | + |
| 189 | +```js |
| 190 | +const myEmitter = new MyEmitter(); |
| 191 | + |
| 192 | +myEmitter.on(EventEmitter.errorMonitor, (err) => { |
| 193 | + MyMonitoringTool.log(err); |
| 194 | +}); |
| 195 | + |
| 196 | +myEmitter.emit('error', new Error('whoops!')); |
| 197 | +// Still throws and crashes Node.js |
| 198 | +``` |
| 199 | + |
| 200 | +Gerhard Stoebich [#30932](https://github.com/nodejs/node/pull/30932). |
| 201 | + |
| 202 | +___ |
| 203 | + |
| 204 | +Using `async` functions with event handlers is problematic, because it |
| 205 | +can lead to an unhandled rejection in case of a thrown exception: |
| 206 | + |
| 207 | +```js |
| 208 | +const ee = new EventEmitter(); |
| 209 | + |
| 210 | +ee.on('something', async (value) => { |
| 211 | + throw new Error('kaboom'); |
| 212 | +}); |
| 213 | +``` |
| 214 | + |
| 215 | +The `captureRejections` option in the `EventEmitter` constructor or the global |
| 216 | +setting change this behavior, installing a `.then(undefined, handler)` handler |
| 217 | +on the `Promise`. This handler routes the exception asynchronously to the |
| 218 | +`Symbol.for('nodejs.rejection')` method if there is one, or to the `'error'` |
| 219 | +event handler if there is none. |
| 220 | + |
| 221 | +```js |
| 222 | +const ee1 = new EventEmitter({ captureRejections: true }); |
| 223 | +ee1.on('something', async (value) => { |
| 224 | + throw new Error('kaboom'); |
| 225 | +}); |
| 226 | + |
| 227 | +ee1.on('error', console.log); |
| 228 | + |
| 229 | +const ee2 = new EventEmitter({ captureRejections: true }); |
| 230 | +ee2.on('something', async (value) => { |
| 231 | + throw new Error('kaboom'); |
| 232 | +}); |
| 233 | + |
| 234 | +ee2[Symbol.for('nodejs.rejection')] = console.log; |
| 235 | +``` |
| 236 | + |
| 237 | +Setting `EventEmitter.captureRejections = true` will change the default for all |
| 238 | +new instances of `EventEmitter`. |
| 239 | + |
| 240 | +```js |
| 241 | +EventEmitter.captureRejections = true; |
| 242 | +const ee1 = new EventEmitter(); |
| 243 | +ee1.on('something', async (value) => { |
| 244 | + throw new Error('kaboom'); |
| 245 | +}); |
| 246 | + |
| 247 | +ee1.on('error', console.log); |
| 248 | +``` |
| 249 | + |
| 250 | +This is an experimental feature. |
| 251 | + |
| 252 | +Matteo Collina [#27867](https://github.com/nodejs/node/pull/27867). |
| 253 | + |
| 254 | +##### Other |
| 255 | + |
| 256 | +* **dgram**: add source-specific multicast support (Lucas Pardue) [#15735](https://github.com/nodejs/node/pull/15735) |
| 257 | +* **esm**: unflag --experimental-exports (Guy Bedford) [#29867](https://github.com/nodejs/node/pull/29867) |
| 258 | +* **fs**: add `bufferSize` option to `fs.opendir()` (Anna Henningsen) [#30114](https://github.com/nodejs/node/pull/30114) |
| 259 | +* **http**: outgoing cork (Robert Nagy) [#29053](https://github.com/nodejs/node/pull/29053) |
| 260 | +* **http**: support readable hwm in IncomingMessage (Colin Ihrig) [#30135](https://github.com/nodejs/node/pull/30135) |
| 261 | +* **http**: add reusedSocket property on client request (themez) [#29715](https://github.com/nodejs/node/pull/29715) |
| 262 | +* **http2**: make maximum tolerated rejected streams configurable (Denys Otrishko) [#30534](https://github.com/nodejs/node/pull/30534) |
| 263 | +* **http2**: allow to configure maximum tolerated invalid frames (Denys Otrishko) [#30534](https://github.com/nodejs/node/pull/30534) |
| 264 | +* **https**: add client support for TLS keylog events (Sam Roberts) [#30053](https://github.com/nodejs/node/pull/30053) |
| 265 | +* **module**: resolve self-references (Jan Krems) [#29327](https://github.com/nodejs/node/pull/29327) |
| 266 | +* **n-api**: add `napi\_detach\_arraybuffer` (legendecas) [#29768](https://github.com/nodejs/node/pull/29768) |
| 267 | +* **perf_hooks**: move perf\_hooks out of experimental (legendecas) [#31101](https://github.com/nodejs/node/pull/31101) |
| 268 | +* **readline**: promote \_getCursorPos to public api (Jeremy Albright) [#30687](https://github.com/nodejs/node/pull/30687) |
| 269 | +* **repl**: check for NODE\_REPL\_EXTERNAL\_MODULE (Gus Caplan) [#29778](https://github.com/nodejs/node/pull/29778) |
| 270 | +* **src**: expose ArrayBuffer version of Buffer::New() (Anna Henningsen) [#30476](https://github.com/nodejs/node/pull/30476) |
| 271 | +* **src**: expose ability to set options (Shelley Vohr) [#30466](https://github.com/nodejs/node/pull/30466) |
| 272 | +* **src**: allow adding linked bindings to Environment (Anna Henningsen) [#30274](https://github.com/nodejs/node/pull/30274) |
| 273 | +* **src**: deprecate two- and one-argument AtExit() (Anna Henningsen) [#30227](https://github.com/nodejs/node/pull/30227) |
| 274 | +* **src**: expose granular SetIsolateUpForNode (Shelley Vohr) [#30150](https://github.com/nodejs/node/pull/30150) |
| 275 | +* **stream**: add writableCorked to Duplex (Anna Henningsen) [#29053](https://github.com/nodejs/node/pull/29053) |
| 276 | +* **stream**: add writableCorked property (Robert Nagy) [#29012](https://github.com/nodejs/node/pull/29012) |
| 277 | +* **tls**: add PSK support (Denys Otrishko) [#23188](https://github.com/nodejs/node/pull/23188) |
| 278 | +* **tls**: expose IETF name for current cipher suite (Sam Roberts) [#30637](https://github.com/nodejs/node/pull/30637) |
| 279 | +* **tls**: cli option to enable TLS key logging to file (Sam Roberts) [#30055](https://github.com/nodejs/node/pull/30055) |
| 280 | +* **util**: add more predefined color codes to inspect.colors (Ruben Bridgewater) [#30659](https://github.com/nodejs/node/pull/30659) |
| 281 | +* **vm**: add Synthetic modules (Gus Caplan) [#29864](https://github.com/nodejs/node/pull/29864) |
| 282 | +* **wasi**: introduce initial WASI support (Colin Ihrig) [#30258](https://github.com/nodejs/node/pull/30258) |
| 283 | +* **worker**: add argv constructor option (legendecas) [#30559](https://github.com/nodejs/node/pull/30559) |
| 284 | +* **worker**: allow specifying resource limits (Anna Henningsen) [#26628](https://github.com/nodejs/node/pull/26628) |
61 | 285 |
|
62 | 286 | ### Commits |
63 | 287 |
|
|
303 | 527 | * [[`a534058d3c`](https://github.com/nodejs/node/commit/a534058d3c)] - **http2**: small clean up in OnStreamRead (Denys Otrishko) [#30351](https://github.com/nodejs/node/pull/30351) |
304 | 528 | * [[`fb4f71bff7`](https://github.com/nodejs/node/commit/fb4f71bff7)] - **(SEMVER-MINOR)** **http2**: make maximum tolerated rejected streams configurable (Denys Otrishko) [#30534](https://github.com/nodejs/node/pull/30534) |
305 | 529 | * [[`3bed1fa7da`](https://github.com/nodejs/node/commit/3bed1fa7da)] - **(SEMVER-MINOR)** **http2**: allow to configure maximum tolerated invalid frames (Denys Otrishko) [#30534](https://github.com/nodejs/node/pull/30534) |
306 | | -* [[`46cb0da9bf`](https://github.com/nodejs/node/commit/46cb0da9bf)] - **(SEMVER-MINOR)** **http2**: replace direct array usage with struct for js\_fields\_ (Denys Otrishko) [#30534](https://github.com/nodejs/node/pull/30534) |
| 530 | +* [[`46cb0da9bf`](https://github.com/nodejs/node/commit/46cb0da9bf)] - **http2**: replace direct array usage with struct for js\_fields\_ (Denys Otrishko) [#30534](https://github.com/nodejs/node/pull/30534) |
307 | 531 | * [[`3fe37e6e2b`](https://github.com/nodejs/node/commit/3fe37e6e2b)] - **https**: prevent options object from being mutated (Vighnesh Raut) [#31151](https://github.com/nodejs/node/pull/31151) |
308 | 532 | * [[`dc521b03a2`](https://github.com/nodejs/node/commit/dc521b03a2)] - **(SEMVER-MINOR)** **https**: add client support for TLS keylog events (Sam Roberts) [#30053](https://github.com/nodejs/node/pull/30053) |
309 | 533 | * [[`a8bf7db040`](https://github.com/nodejs/node/commit/a8bf7db040)] - **inspector**: do not access queueMicrotask from global (Michaël Zasso) [#30732](https://github.com/nodejs/node/pull/30732) |
|
493 | 717 | * [[`b9c057c85a`](https://github.com/nodejs/node/commit/b9c057c85a)] - **tools,src**: forbid usage of v8::Persistent (Anna Henningsen) [#31018](https://github.com/nodejs/node/pull/31018) |
494 | 718 | * [[`70dc7a2672`](https://github.com/nodejs/node/commit/70dc7a2672)] - **url**: declare iterator inside loop (Trivikram Kamat) [#30509](https://github.com/nodejs/node/pull/30509) |
495 | 719 | * [[`219c8e9885`](https://github.com/nodejs/node/commit/219c8e9885)] - **(SEMVER-MINOR)** **util**: add more predefined color codes to inspect.colors (Ruben Bridgewater) [#30659](https://github.com/nodejs/node/pull/30659) |
496 | | -* [[`1fbd7ac32e`](https://github.com/nodejs/node/commit/1fbd7ac32e)] - **(SEMVER-MINOR)** **util**: improve inspect's customInspect performance (Ruben Bridgewater) [#30659](https://github.com/nodejs/node/pull/30659) |
| 720 | +* [[`1fbd7ac32e`](https://github.com/nodejs/node/commit/1fbd7ac32e)] - **util**: improve inspect's customInspect performance (Ruben Bridgewater) [#30659](https://github.com/nodejs/node/pull/30659) |
497 | 721 | * [[`5aecbcfdbe`](https://github.com/nodejs/node/commit/5aecbcfdbe)] - **util**: add internal sleep() function (Colin Ihrig) [#30787](https://github.com/nodejs/node/pull/30787) |
498 | 722 | * [[`74f7844a71`](https://github.com/nodejs/node/commit/74f7844a71)] - **v8**: use of TypedArray constructors from primordials (Sebastien Ahkrin) [#30740](https://github.com/nodejs/node/pull/30740) |
499 | 723 | * [[`faf3ad2cb4`](https://github.com/nodejs/node/commit/faf3ad2cb4)] - **(SEMVER-MINOR)** **vm**: add Synthetic modules (Gus Caplan) [#29864](https://github.com/nodejs/node/pull/29864) |
|
0 commit comments