Skip to content

Commit 8b03609

Browse files
addaleaxkjin
authored andcommitted
doc: document http2 network error behaviour
Fixes: nodejs#21836 PR-URL: nodejs#21861 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
1 parent f3c9f5a commit 8b03609

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/api/http2.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,17 @@ server.on('stream', (stream, headers) => {
272272
'content-type': 'text/html',
273273
':status': 200
274274
});
275+
stream.on('error', (error) => console.error(error));
275276
stream.end('<h1>Hello World</h1>');
276277
});
277278

278279
server.listen(80);
279280
```
280281

282+
Even though HTTP/2 streams and network sockets are not in a 1:1 correspondence,
283+
a network error will destroy each individual stream and must be handled on the
284+
stream level, as shown above.
285+
281286
#### Event: 'timeout'
282287
<!-- YAML
283288
added: v8.4.0

0 commit comments

Comments
 (0)