| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
This is a lot to digest, I'll do my best to review asap, but it might happen in a while. Can you also update the docs accordingly? I think we should document what you are doing with the Proxy.
👍 on the Express compatibility.
Sorry, something went wrong.
|
Thanks @mcollina! Pushed a tiny change that got rid of the unnecessary createProxySocket function (used to do more in it, now I can just call new Proxy directly) and also added setTimeout handler for the proxy (which sets a session timeout) since that's the one other common use case. Update: Also correctly binding socket functions now. Will work on docs and add a commit either later today or sometime the coming week. |
Sorry, something went wrong.
There was a problem hiding this comment.
What's this? I can't see this is a part of the official h1 api?
Sorry, something went wrong.
There was a problem hiding this comment.
It's not documented but libraries use it.
Sorry, something went wrong.
There was a problem hiding this comment.
We check that name is valid but not value?
Sorry, something went wrong.
There was a problem hiding this comment.
assertValidHeader(name, value); takes care of value. We're going to properly validate name & value further downstream at some point (outside of compat), not yet implemented.
Sorry, something went wrong.
There was a problem hiding this comment.
Should request === undefined even be possible here?
Sorry, something went wrong.
There was a problem hiding this comment.
Technically? Yes. Likely? No.
Sorry, something went wrong.
There was a problem hiding this comment.
These need to be added to the docs in /doc/api/http2.md. Should be done in this PR but can be done in a separate one if necessary
Sorry, something went wrong.
There was a problem hiding this comment.
Code changes LGTM with green CI.
Would prefer docs to be updated in this PR tho.
Really great to see this!
Sorry, something went wrong.
|
@jasnell I've been thinking over the socket warning a bit more and I'm wondering if we really should have it or not... There are some legitimate reasons to access the socket, such as with the address-related stuff but also for TLS, for stuff like getPeerCertificate(), getSession(), etc. Realistically, it's not like we want to maintain the whole range of socket-related getters, setters and methods on the session. And it seems somewhat arbitrary as to what we actually expose on the session and what we don't. I'm personally almost leaning towards removing the 2nd commit (http2: add socket address getters on session) and adjusting the warning to only appear if users try to use stuff like resume, pause, read, write or end on the socket proxy. Thoughts? |
Sorry, something went wrong.
|
Yeah, I know getting to this information is important, it's just a really bad idea to expose the socket easily with http2 connections. We've seen things like that come back and bite us in the past. Let me stew on this a bit more to see if I can think of a reasonable alternative... if there's not, then I'm good with dropping the warning for now. |
Sorry, something went wrong.
|
Sounds good. I think my preferred option is to have the warning just for certain methods as mentioned above (the ones that are actually destructive) but I realize that would only apply to compatibility mode and anyone using the proper http2 API wouldn't hear a peep. |
Sorry, something went wrong.
|
I'm 👍 on having the warning on some of the stream-related APIs. In fact, I would not make it a warning, but I'd rather throw. If you are calling one of those methods you definitely have a bug. |
Sorry, something went wrong.
Extensive re-work of http1 compatibility layer based on tests in express, on-finished and finalhandler. Fix handling of HEAD method to match http1. Adjust write, end, etc. to call writeHead as in http1 and as expected by user-land modules. Add socket proxy that instead uses the Http2Stream for the vast majority of socket interactions. Add and change tests to closer represent http1 behaviour. Refs: nodejs#15633 Refs: https://github.com/expressjs/express/tree/master/test Refs: https://github.com/jshttp/on-finished/blob/master/test/test.js Refs: https://github.com/pillarjs/finalhandler/blob/master/test/test.js
|
Ok, I've got an updated version ready to go just in case. It throws ERR_HTTP2_NO_SOCKET_MANIPULATION with the following message
if the user tries to read, write, pause or resume the request.socket or response.socket. I added end to the list of things that are called on stream since hapi seems to use it. It also removes the socket warning and the socket address related getters. Will commit or adjust further once there's consensus. Working on the docs at the moment so should have those ready sometime tomorrow. |
Sorry, something went wrong.
|
Ok, I've force pushed a commit with updates as per above and a new commit with the doc changes (plus some formatting fixes as we had the wrong heading levels for a lot of the compatibility stuff). |
Sorry, something went wrong.
|
Still LGTM with green CI :-) |
Sorry, something went wrong.
Sorry, something went wrong.
Extensive re-work of http1 compatibility layer based on tests in express, on-finished and finalhandler. Fix handling of HEAD method to match http1. Adjust write, end, etc. to call writeHead as in http1 and as expected by user-land modules. Add socket proxy that instead uses the Http2Stream for the vast majority of socket interactions. Add and change tests to closer represent http1 behaviour. Refs: #15633 Refs: https://github.com/expressjs/express/tree/master/test Refs: https://github.com/jshttp/on-finished/blob/master/test/test.js Refs: https://github.com/pillarjs/finalhandler/blob/master/test/test.js PR-URL: #15702 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Extensive re-work of http1 compatibility layer based on tests in express, on-finished and finalhandler. Fix handling of HEAD method to match http1. Adjust write, end, etc. to call writeHead as in http1 and as expected by user-land modules. Add socket proxy that instead uses the Http2Stream for the vast majority of socket interactions. Add and change tests to closer represent http1 behaviour. Refs: #15633 Refs: https://github.com/expressjs/express/tree/master/test Refs: https://github.com/jshttp/on-finished/blob/master/test/test.js Refs: https://github.com/pillarjs/finalhandler/blob/master/test/test.js PR-URL: #15702 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Extensive re-work of http1 compatibility layer based on tests in express, on-finished and finalhandler. Fix handling of HEAD method to match http1. Adjust write, end, etc. to call writeHead as in http1 and as expected by user-land modules. Add socket proxy that instead uses the Http2Stream for the vast majority of socket interactions. Add and change tests to closer represent http1 behaviour. Refs: #15633 Refs: https://github.com/expressjs/express/tree/master/test Refs: https://github.com/jshttp/on-finished/blob/master/test/test.js Refs: https://github.com/pillarjs/finalhandler/blob/master/test/test.js PR-URL: #15702 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Extensive re-work of http1 compatibility layer based on tests in express, on-finished and finalhandler. Fix handling of HEAD method to match http1. Adjust write, end, etc. to call writeHead as in http1 and as expected by user-land modules. Add socket proxy that instead uses the Http2Stream for the vast majority of socket interactions. Add and change tests to closer represent http1 behaviour. Refs: nodejs/node#15633 Refs: https://github.com/expressjs/express/tree/master/test Refs: https://github.com/jshttp/on-finished/blob/master/test/test.js Refs: https://github.com/pillarjs/finalhandler/blob/master/test/test.js PR-URL: nodejs/node#15702 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
| Back | FazBrowse Home | New Git URL |
As a preface, this is a lot of changes but I had no way to separate them out into small chunks due to the order in which they happened. I started with working on support for HEAD requests and other minor http2 tweaks but as I got the express & on-finished test suites to work, I had to change a ton of that code and as a result it's hard for me to separate it out since some of these changes have broader effect on the compatibility layer.
With this PR we pass 100% of tests in express & on-finished that are applicable to http2. (There are tests in on-finished that don't apply re: handling upgrade and there are 4 tests in express that use a 3rd party module that we can't do anything about because it uses http1 prototype directly.)
Full or near full list of changes follows:
Performance has actually improved by about 5% with all of the changes in here, even when accessing the socket — despite the use of a Proxy.
Please let me know if I can provide more info for any of these changes. It came a long way since I started this work.
cc @jasnell, @mcollina & @dougwilson
Checklist
Affected core subsystem(s)
http2, test