doc: document http2 network error behaviour
Fixes: https://github.com/nodejs/node/issues/21836 PR-URL: https://github.com/nodejs/node/pull/21861 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
This commit is contained in:
parent
daa15b54ba
commit
0e4cbde13b
@ -271,12 +271,17 @@ server.on('stream', (stream, headers) => {
|
|||||||
'content-type': 'text/html',
|
'content-type': 'text/html',
|
||||||
':status': 200
|
':status': 200
|
||||||
});
|
});
|
||||||
|
stream.on('error', (error) => console.error(error));
|
||||||
stream.end('<h1>Hello World</h1>');
|
stream.end('<h1>Hello World</h1>');
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(80);
|
server.listen(80);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Even though HTTP/2 streams and network sockets are not in a 1:1 correspondence,
|
||||||
|
a network error will destroy each individual stream and must be handled on the
|
||||||
|
stream level, as shown above.
|
||||||
|
|
||||||
#### Event: 'timeout'
|
#### Event: 'timeout'
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v8.4.0
|
added: v8.4.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user