-
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
Document error handling in http2 client connect example #16345
Comments
that won't throw. Try adding a |
Isn't that a race, trying to add an error handler after calling connect?
|
No. The underlying code is specifically designed to handle connection errors asynchronously. Attaching the handler after should work just fine |
I added a
Output:
|
Socket errors are actually emitted on Here's the documentation for it: https://nodejs.org/dist/latest-v8.x/docs/api/http2.html#http2_event_socketerror |
Ha! Sigh that's right. Thank you for the correction @apapirovski! |
Thanks, that worked! I updated the issue title to suggest updating the example code for client usage to reflect handling As general feedback: I spent a while reading the http2 documentation, and to me it wasn't clear which methods apply to client usage vs server usage. The impression I'm starting to come to is that the http2 API is much more "symmetric" than the http API, in that lots of the events apply to both sides. Is that accurate? If so, the documentation might benefit from explaining this up front, and/or documenting for each event whether it can be thrown by clients or servers. Thanks, |
I would say that's correct, yes — both the client and the server use the same basic building blocks in Http2Session & Http2Stream. The session is almost identical between client & server. There are a few more differences for the stream which you can see here: https://nodejs.org/dist/latest-v8.x/docs/api/http2.html#http2_class_clienthttp2stream In general, we are VERY happy to accept PRs that improve the docs. If you would like to add an example illustrating error handling or expand the existing example, that would be amazing! |
Done: #16366. Another bit of clarification: Is the compatibility API intended to include client-side code? I tried to port some existing code that used the |
The compatibility layer is strictly server side at the moment. For the client-side, I don't know if there's any plan to make it fully h1 compatible but — as far as I understand — we at the very least want to add something similar to the h1 Agent model. I'm surprised |
Provide section headings for server-side and client side examples. Add error handling and TLS to server-side example, following example of `https`. Add error handling, TLS, more efficient Buffer usage, and header printing to client example. PR-URL: nodejs/node#16366 Fixes: nodejs/node#16345 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Provide section headings for server-side and client side examples. Add error handling and TLS to server-side example, following example of `https`. Add error handling, TLS, more efficient Buffer usage, and header printing to client example. PR-URL: #16366 Fixes: #16345 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Provide section headings for server-side and client side examples. Add error handling and TLS to server-side example, following example of `https`. Add error handling, TLS, more efficient Buffer usage, and header printing to client example. PR-URL: #16366 Fixes: #16345 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Provide section headings for server-side and client side examples. Add error handling and TLS to server-side example, following example of `https`. Add error handling, TLS, more efficient Buffer usage, and header printing to client example. PR-URL: #16366 Fixes: #16345 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Provide section headings for server-side and client side examples. Add error handling and TLS to server-side example, following example of `https`. Add error handling, TLS, more efficient Buffer usage, and header printing to client example. PR-URL: nodejs/node#16366 Fixes: nodejs/node#16345 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Steps to reproduce:
Run the below program with
node --expose_http2 sample.js
Expected result:
An error with ECONNREFUSED is thrown.
Actual result:
Program exits with no output.
The text was updated successfully, but these errors were encountered: