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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ release.
</tr>
<tr>
<td valign="top">
<b><a href="doc/changelogs/CHANGELOG_V26.md#26.2.0">26.2.0</a></b><br/>
<b><a href="doc/changelogs/CHANGELOG_V26.md#26.3.0">26.3.0</a></b><br/>
<a href="doc/changelogs/CHANGELOG_V26.md#26.2.0">26.2.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V26.md#26.1.0">26.1.0</a><br/>
<a href="doc/changelogs/CHANGELOG_V26.md#26.0.0">26.0.0</a><br/>
</td>
Expand Down
4 changes: 2 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
valid_mips_float_abi = ('soft', 'hard')
valid_intl_modes = ('none', 'small-icu', 'full-icu', 'system-icu')
icu_versions = json.loads((tools_path / 'icu' / 'icu_versions.json').read_text(encoding='utf-8'))
maglev_enabled_architectures = ('x64', 'arm', 'arm64', 's390x')
maglev_enabled_architectures = ('x64', 'arm', 'arm64', 'ppc64', 's390x')

# builtins may be removed later if they have been disabled by options
shareable_builtins = {'undici/undici': 'deps/undici/undici.js',
Expand Down Expand Up @@ -2175,7 +2175,7 @@ def configure_v8(o, configs):
o['variables']['v8_promise_internal_field_count'] = 1 # Add internal field to promises for async hooks.
o['variables']['v8_use_siphash'] = 0 if options.without_siphash else 1
o['variables']['v8_enable_maglev'] = B(not options.v8_disable_maglev and
flavor != 'zos' and
flavor not in ('aix', 'os400', 'zos') and
o['variables']['target_arch'] in maglev_enabled_architectures)
o['variables']['v8_enable_pointer_compression'] = 1 if options.enable_pointer_compression else 0
# Using the sandbox requires always allocating array buffer backing stores in the sandbox.
Expand Down
2 changes: 1 addition & 1 deletion doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ console.log(Buffer.isEncoding(''));
<!-- YAML
added: v0.11.3
changes:
- version: REPLACEME
- version: v26.3.0
pr-url: https://github.com/nodejs/node/pull/63597
description: Default raised from 8192 to 65536.
-->
Expand Down
2 changes: 1 addition & 1 deletion doc/api/debugger.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ added:
- v26.1.0
- v24.16.0
changes:
- version: REPLACEME
- version: v26.3.0
pr-url: https://github.com/nodejs/node/pull/63437
description: Add `probe_failure` terminal `error` event for inspector-side mid-session
failures, and `error.details` for additional context on per-hit and terminal errors.
Expand Down
55 changes: 55 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4574,7 +4574,62 @@
may lead to subtle bugs. Calling `hmac.digest()` on a finalized `Hmac` instance
will throw an error in a future version.

### DEP0207: `.aborted` property and `'aborted'` event in `http2`

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/63249

Check warning on line 4582 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: Documentation-only deprecation.
-->

Type: Documentation-only

Use standard stream events and state checks instead. Read-side aborts
(peer cancelled before sending `END_STREAM`) now surface as `'error'`
with code `ERR_HTTP2_STREAM_ABORTED` (clean peer reset code) or
`ERR_HTTP2_STREAM_ERROR` (non-clean code). Write-side aborts (peer
cancelled while we still had writes in flight) are detectable from
`'close'` by checking `writableFinished`. Parallels [DEP0156][] for
`http`.

```cjs
// Deprecated
server.on('stream', (stream) => {
stream.on('aborted', () => {
// Stream was closed while the writable was still open.
});
});
```

```cjs
// Use this instead
server.on('stream', (stream) => {
// Read-side abort: peer cancelled before sending END_STREAM.
stream.on('error', (err) => {
if (err.code === 'ERR_HTTP2_STREAM_ABORTED' ||
err.code === 'ERR_HTTP2_STREAM_ERROR') {
// Peer cancelled the request mid-stream.
}
});
// Write-side abort: our response didn't fully send before close.
stream.on('close', () => {
if (!stream.writableFinished) {
// Writes were aborted (peer cancel, local destroy, etc.).
}
});
});
```

The same patterns apply to the compatibility API (`req` / `res` on
`http2.createServer((req, res) => …)`). On the read-side, errors on the
underlying stream are emitted from `req`. On the write-side you can use
`res.on('close', …)` to hear about client aborts by checking
`res.writableFinished` to confirm whether the response was written
successfully before the response closed.

[DEP0142]: #dep0142-repl_builtinlibs
[DEP0156]: #dep0156-aborted-property-and-abort-aborted-event-in-http
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
[RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4
Expand Down
9 changes: 9 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,15 @@ Use of the `101` Informational status code is forbidden in HTTP/2.
An invalid HTTP status code has been specified. Status codes must be an integer
between `100` and `599` (inclusive).

<a id="ERR_HTTP2_STREAM_ABORTED"></a>

### `ERR_HTTP2_STREAM_ABORTED`

The peer reset the `Http2Stream` with a clean error code (`NGHTTP2_NO_ERROR`
or `NGHTTP2_CANCEL`) before sending `END_STREAM`, so the readable side will
not be fully delivered. Mirrors HTTP/1's `ECONNRESET` for a peer-side
`socket.destroy()`.

<a id="ERR_HTTP2_STREAM_CANCEL"></a>

### `ERR_HTTP2_STREAM_CANCEL`
Expand Down
4 changes: 2 additions & 2 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -3680,7 +3680,7 @@ Found'`.
<!-- YAML
added: v0.1.13
changes:
- version: REPLACEME
- version: v26.3.0
pr-url: https://github.com/nodejs/node/pull/61597
description: The `httpValidation` option is supported now.
- version:
Expand Down Expand Up @@ -4005,7 +4005,7 @@ This can be overridden for servers and client requests by passing the
<!-- YAML
added: v0.3.6
changes:
- version: REPLACEME
- version: v26.3.0
pr-url: https://github.com/nodejs/node/pull/61597
description: The `httpValidation` option is supported now.
- version:
Expand Down
89 changes: 60 additions & 29 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1238,22 +1238,23 @@

##### Destruction

All [`Http2Stream`][] instances are destroyed either when:
All [`Http2Stream`][] instances are destroyed when one of the following
happens:

* An `RST_STREAM` frame for the stream is received by the connected peer,
and (for client streams only) pending data has been read.
* The `http2stream.close()` method is called, and (for client streams only)
pending data has been read.
* The `http2stream.destroy()` or `http2session.destroy()` methods are called.
* Both sides send `END_STREAM` (a clean exchange).
* The peer sends an `RST_STREAM` frame.
* `http2stream.close()`, `http2stream.destroy()`, or `http2session.destroy()`
is called locally.

When an `Http2Stream` instance is destroyed, an attempt will be made to send an
`RST_STREAM` frame to the connected peer.
For clean exchanges and clean cancels, the destroy is deferred until any
pending `'end'` and `'finish'` events have fired. When destroyed, an
attempt is made to send an `RST_STREAM` frame to the connected peer if
one hasn't already been sent.

When the `Http2Stream` instance is destroyed, the `'close'` event will
be emitted. Because `Http2Stream` is an instance of `stream.Duplex`, the
`'end'` event will also be emitted if the stream data is currently flowing.
The `'error'` event may also be emitted if `http2stream.destroy()` was called
with an `Error` passed as the first argument.
`'close'` is always emitted on destroy. `'end'` and `'finish'` fire if
their respective halves completed before destroy. `'error'` fires when
the destroy carries an error — either via `http2stream.destroy(err)`,
or when the peer reset the stream before sending `END_STREAM`.

After the `Http2Stream` has been destroyed, the `http2stream.destroyed`
property will be `true` and the `http2stream.rstCode` property will specify the
Expand All @@ -1264,14 +1265,18 @@

<!-- YAML
added: v8.4.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/63249

Check warning on line 1270 in doc/api/http2.md

View workflow job for this annotation

GitHub Actions / lint-pr-url

pr-url doesn't match the URL of the current PR.
description: Documentation-only deprecation.
-->

The `'aborted'` event is emitted whenever a `Http2Stream` instance is
abnormally aborted in mid-communication.
Its listener does not expect any arguments.
> Stability: 0 - Deprecated. Use `'close'` and `'error'` plus
> `stream.destroyed`.

The `'aborted'` event will only be emitted if the `Http2Stream` writable side
has not been ended.
Emitted when an `Http2Stream` is closed before the writable side has
been ended (via `.end()` or auto-ended via `respond({ endStream: true })`).
Listeners receive no arguments.

#### Event: `'close'`

Expand All @@ -1283,19 +1288,29 @@
this event is emitted, the `Http2Stream` instance is no longer usable.

The HTTP/2 error code used when closing the stream can be retrieved using
the `http2stream.rstCode` property. If the code is any value other than
`NGHTTP2_NO_ERROR` (`0`), an `'error'` event will have also been emitted.
the `http2stream.rstCode` property.

#### Event: `'error'`

<!-- YAML
added: v8.4.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/63249

Check warning on line 1299 in doc/api/http2.md

View workflow job for this annotation

GitHub Actions / lint-pr-url

pr-url doesn't match the URL of the current PR.
description: >-
Also emitted on peer-initiated resets that arrive before
`END_STREAM` (`ERR_HTTP2_STREAM_ABORTED` for clean codes,
`ERR_HTTP2_STREAM_ERROR` otherwise). Locally-initiated resets
without an explicit error remain silent.
-->

* `error` {Error}

The `'error'` event is emitted when an error occurs during the processing of
an `Http2Stream`.
Emitted when an error occurs processing the `Http2Stream`. This includes
peer-initiated resets that arrive before the readable side has been
fully delivered: a clean reset code (`NGHTTP2_NO_ERROR` or
`NGHTTP2_CANCEL`) surfaces as [`ERR_HTTP2_STREAM_ABORTED`][], any other
code as [`ERR_HTTP2_STREAM_ERROR`][].

#### Event: `'frameError'`

Expand Down Expand Up @@ -1378,8 +1393,8 @@

* Type: {boolean}

Set to `true` if the `Http2Stream` instance was aborted abnormally. When set,
the `'aborted'` event will have been emitted.
`true` if the `Http2Stream` was closed while the writable side was
still open. When set, the `'aborted'` event was emitted.

#### `http2stream.bufferSize`

Expand Down Expand Up @@ -1723,6 +1738,13 @@

<!-- YAML
added: v8.4.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/63249

Check warning on line 1743 in doc/api/http2.md

View workflow job for this annotation

GitHub Actions / lint-pr-url

pr-url doesn't match the URL of the current PR.
description: >-
If no `'response'` listener is attached when the response headers
arrive, the response body is now silently discarded - matching
the `lib/http` client behaviour.
-->

* `headers` {HTTP/2 Headers Object}
Expand All @@ -1744,6 +1766,16 @@
});
```

If no `'response'` listener is attached at the moment the response
arrives, the response body will be entirely discarded (the stream is
silently resumed). However, if a `'response'` listener is added, the
data from the response object **must** be consumed — either by calling
`response.read()` whenever there is a `'readable'` event, by adding a
`'data'` handler, or by calling the `.resume()` method. Until the data
is consumed, the `'end'` event will not fire. Also, until the data is
read, it will consume memory that can eventually lead to a "process
out of memory" error.

```cjs
const http2 = require('node:http2');
const client = http2.connect('https://localhost');
Expand Down Expand Up @@ -4035,11 +4067,8 @@
added: v8.4.0
-->

The `'aborted'` event is emitted whenever a `Http2ServerRequest` instance is
abnormally aborted in mid-communication.

The `'aborted'` event will only be emitted if the `Http2ServerRequest` writable
side has not been ended.
The `'aborted'` event is emitted whenever a `Http2ServerRequest` instance
is closed while the underlying writable side is still open.

#### Event: `'close'`

Expand Down Expand Up @@ -5050,6 +5079,8 @@
[`'unknownProtocol'`]: #event-unknownprotocol
[`ClientHttp2Stream`]: #class-clienthttp2stream
[`Duplex`]: stream.md#class-streamduplex
[`ERR_HTTP2_STREAM_ABORTED`]: errors.md#err_http2_stream_aborted
[`ERR_HTTP2_STREAM_ERROR`]: errors.md#err_http2_stream_error
[`Http2ServerRequest`]: #class-http2http2serverrequest
[`Http2ServerResponse`]: #class-http2http2serverresponse
[`Http2Session` and Sockets]: #http2session-and-sockets
Expand Down
2 changes: 1 addition & 1 deletion doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -3171,7 +3171,7 @@ process.permission.has('fs.read');
### `process.permission.drop(scope[, reference])`

<!-- YAML
added: REPLACEME
added: v26.3.0
-->

> Stability: 1.1 - Active Development
Expand Down
Loading
Loading