Skip to content
Open
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
52 changes: 52 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4541,6 +4541,17 @@ const server = http2.createSecureServer({
});
```

```mjs
import { createSecureServer } from 'node:http2';

// Deprecated
const server = createSecureServer({
allowHTTP1: true,
Http1IncomingMessage: MyIncomingMessage,
Http1ServerResponse: MyServerResponse,
});
```

```cjs
// Use this instead
const server = http2.createSecureServer({
Expand All @@ -4552,6 +4563,19 @@ const server = http2.createSecureServer({
});
```

```mjs
import { createSecureServer } from 'node:http2';

// Use this instead
const server = createSecureServer({
allowHTTP1: true,
http1Options: {
IncomingMessage: MyIncomingMessage,
ServerResponse: MyServerResponse,
},
});
```

### DEP0203: Passing `CryptoKey` to `node:crypto` APIs

<!-- YAML
Expand Down Expand Up @@ -4671,6 +4695,15 @@ server.on('stream', (stream) => {
});
```

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

Comment on lines +4698 to +4706

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What value does this bring, your just duplicating the same code

```cjs
// Use this instead
server.on('stream', (stream) => {
Expand All @@ -4690,6 +4723,25 @@ server.on('stream', (stream) => {
});
```

```mjs
// 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
Expand Down
Loading