Skip to content

Conversation

@jasnell
Copy link
Member

Fixes the bug in the sense that a better error message is provided. Generally speaking, once the connection has been closed, users should not continue to the use the socket proxy object. So, throw whenever they try to.

Fixes: #22268

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-botnodejs-github-bot added dont-land-on-v6.x errors Issues and PRs related to JavaScript errors originated in Node.js core. http2 Issues or PRs related to the http2 subsystem. labels Aug 23, 2018
@szmarczak
Copy link
Member

There's another ways to expose the original socket:

session.socket.ref()session.socket.unref()session.socket.setEncoding()session.socket.setKeepAlive()session.socket.setNoDelay()

Should these be fixed?

Copy link
Member

@BridgeARBridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is the ideal solution but the code looks good to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is expected to happen sync?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

@jasnell
Copy link
MemberAuthor

Should these be fixed?

Yeah, I'll take another look.

@szmarczakszmarczak mentioned this pull request Aug 24, 2018
3 tasks
@jasnelljasnellforce-pushed the http2-proxy-socket-unbound branch from 3bb3522 to dc92650CompareAugust 24, 2018 18:27
@jasnell
Copy link
MemberAuthor

Added additional tests for the ref(), unref(), setEncoding(), setKeepAlive(), and setNoDelay() functions.

@jasnell
Copy link
MemberAuthor

@jasnelljasnell added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Aug 24, 2018
@Trott
Copy link
Member

@Trott
Copy link
Member

Trott commented Aug 25, 2018

Theoretically semver-major (I think?) if it doesn't end up in the same release as the "HTTP/2 is stable!" thing, so let's get this thing landed.

I personally don't know that I would have chosen an HTTP2 error for this (and others) instead of one of the existing SOCKET errors, but maybe more specific is good and I make bad decisions. 🙃

@Trott
Copy link
Member

@nodejs/http2

Copy link
Member

@mcollinamcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

jasnell added a commit that referenced this pull request Aug 27, 2018
Fixes: #22268 PR-URL: #22486 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
@jasnell
Copy link
MemberAuthor

Landed in dd03706

@jasnelljasnell closed this Aug 27, 2018
addaleax pushed a commit that referenced this pull request Aug 27, 2018
Fixes: #22268 PR-URL: #22486 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
@szmarczak
Copy link
Member

@jasnell I think you missed something :P

You can't do session.socket.destroy() because it'll throw ERR_HTTP2_NO_SOCKET_MANIPULATION, but you can do session.socket.ref().destroy(). As I said, these functions expose the original socket:

session.socket.ref()session.socket.unref()session.socket.setEncoding()session.socket.setKeepAlive()session.socket.setNoDelay()

So ProxySocket should look like:

get(session,prop){switch(prop){case'setTimeout': returnsession.setTimeout.bind(session);case'destroy': case'emit': case'end': case'pause': case'read': case'resume': case'write': case'setEncoding': case'setKeepAlive': case'setNoDelay': thrownewERR_HTTP2_NO_SOCKET_MANIPULATION();case'ref': case'unref': returnsocket[prop].bind(session.socket);default: constsocket=session[kSocket];if(socket===undefined)thrownewERR_HTTP2_SOCKET_UNBOUND();constvalue=socket[prop];returntypeofvalue==='function' ? value.bind(socket) : value;}} ... set(session,prop,value){switch(prop){case'setTimeout': session.setTimeout=value;returntrue;case'destroy': case'emit': case'end': case'pause': case'read': case'resume': case'write': case'setEncoding': case'setKeepAlive': case'setNoDelay': case'ref': case'unref': thrownewERR_HTTP2_NO_SOCKET_MANIPULATION();default: constsocket=session[kSocket];if(socket===undefined)thrownewERR_HTTP2_SOCKET_UNBOUND();socket[prop]=value;returntrue;}

@mcollina
Copy link
Member

@szmarczak good spot! would you like to open a PR to fix that?

@szmarczak
Copy link
Member

Yeah, sure.

@szmarczak
Copy link
Member

@mcollina Here it is: #22650

targos pushed a commit that referenced this pull request Sep 3, 2018
Fixes: #22268 PR-URL: #22486 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
mcollina pushed a commit that referenced this pull request Sep 5, 2018
Refs: #22486 PR-URL: #22650 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this pull request Sep 5, 2018
Refs: #22486 PR-URL: #22650 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: James M Snell <[email protected]>
@targostargos mentioned this pull request Sep 5, 2018
targos pushed a commit that referenced this pull request Sep 6, 2018
Fixes: #22268 PR-URL: #22486 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
targos pushed a commit that referenced this pull request Sep 6, 2018
Refs: #22486 PR-URL: #22650 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: James M Snell <[email protected]>
kjin pushed a commit to kjin/node that referenced this pull request Oct 3, 2018
Fixes: nodejs#22268 PR-URL: nodejs#22486 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
kjin pushed a commit to kjin/node that referenced this pull request Oct 3, 2018
Refs: nodejs#22486 PR-URL: nodejs#22650 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: James M Snell <[email protected]>
kjin pushed a commit to kjin/node that referenced this pull request Oct 16, 2018
Fixes: nodejs#22268 PR-URL: nodejs#22486 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
kjin pushed a commit to kjin/node that referenced this pull request Oct 16, 2018
Refs: nodejs#22486 PR-URL: nodejs#22650 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: James M Snell <[email protected]>
BethGriggs pushed a commit that referenced this pull request Oct 17, 2018
Fixes: #22268 Backport-PR-URL: #22850 PR-URL: #22486 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
BethGriggs pushed a commit that referenced this pull request Oct 17, 2018
Refs: #22486 Backport-PR-URL: #22850 PR-URL: #22650 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: James M Snell <[email protected]>
@BethGriggsBethGriggs mentioned this pull request Oct 30, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.errorsIssues and PRs related to JavaScript errors originated in Node.js core.http2Issues or PRs related to the http2 subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessing socket after HTTP2 session gets destroyed throws an error

7 participants

@jasnell@nodejs-github-bot@szmarczak@Trott@mcollina@BridgeAR@trivikr