-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test,doc: address http2 connection abort/network error handling #21861
Conversation
doc/api/http2.md
Outdated
stream.end('<h1>Hello World</h1>'); | ||
}); | ||
|
||
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 streams and must be handled on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: streams -> stream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, done!
@nodejs/http2 |
doc/api/http2.md
Outdated
@@ -271,12 +271,17 @@ server.on('stream', (stream, headers) => { | |||
'content-type': 'text/html', | |||
':status': 200 | |||
}); | |||
stream.on('error', (error) => console.log(error)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log
-> console.error
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe just:
stream.on('error', console.error);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Switched to the first suggestion – I’d prefer to give a user-defined function here, since that is a bit closer to what one would actually do in real-world code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
CI: https://ci.nodejs.org/job/node-test-pull-request/15930/ (edit: ✔️) |
@@ -271,12 +271,17 @@ server.on('stream', (stream, headers) => { | |||
'content-type': 'text/html', | |||
':status': 200 | |||
}); | |||
stream.on('error', (error) => console.error(error)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: how about passing console.error
directly? It's already bound. If this is the prevalent usage in the docs, ignore this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes: nodejs#21836 PR-URL: nodejs#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>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes