Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
http2: invoke connect callback immediately if session was connected #19842
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
pietermees commented Apr 5, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
http2.connect callback immediately if the Http2Session was connected synchronouslylpinca commented Apr 6, 2018
Is it possible to add a test? |
BridgeAR commented Apr 6, 2018
@pietermees as @lpinca pointed out, it would be great if you could add a test. There is a documentation for how to write tests in |
BridgeAR commented Apr 6, 2018
@pietermees and thanks a lot for contributing! Great that you went ahead to fix the issue right away 🎉. |
apapirovski left a 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.
There are some changes that need to be made before this lands. A test should definitely be added as it would help the suggested changes below, plus any other potential issues.
lib/internal/http2/core.js Outdated
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.
The context passed to the listener should be session rather than this from the current scope. Also, please use Reflect.apply(listener, session, [socket]); for user-provided callbacks.
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.
fixed in 1fee57b30601f351c5b8eb60d2797917c0604a6b
pietermees commented Apr 6, 2018
In d575ac7a49ca38f84fcd20f4ef0a01786e3e0f23 I added documentation for the |
pietermees commented Apr 6, 2018
And I'll add a test :) |
BridgeAR left a 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.
Just the comment about the version.
doc/api/http2.md Outdated
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.
This should not be a fixed value. Instead of v9.12.0 just put in: REPLACEME. This is going to be automatically be replaced during publishing a new release.
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.
Fixed in 8316d4f36b769fdf3224b65fdd32f4194a441ada
doc/api/http2.md Outdated
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.
Just a hint: the Value will probably be removed soon. See #19869. If that lands before this PR, this should get a update and vice versa.
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.
Update: it just landed and now the Value should be removed ;-)
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.
It seems this is a new section, so no conflicts for now, but the * Value:{boolean} should b replaced with just *{boolean}.
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.
Fixed in 8316d4f36b769fdf3224b65fdd32f4194a441ada
lib/internal/http2/core.js Outdated
apapirovskiApr 9, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
@jasnell@mcollina Thinking about this a bit more, should we use process.nextTick and emit a connect event regardless rather than directly calling the listener? I know we don't recommend this code pattern anywhere but something like the following would still not work after this change:
constsession=http2.connect(SERVER_URL,{createConnection: ()=>socket});session.once('connect',listener);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.
@apapirovski I think we should copy-paste what we are doing for http, https, net and tls. So, we should adhere to the prevailing pattern.
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.
I'm good with emitting on nextTick
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.
We actually do emit connect though on the following lines:
node/lib/internal/http2/core.js
Line 777 in e37effe
this.emit('connect',this,socket); node/lib/internal/http2/core.js
Line 819 in e37effe
this.emit('connect',this,socket);
So I guess we're saying that we'll register the listener as a connect listener and change the two emits to run on the next tick?
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.
See f21670f5d51d451cd2f2203f14d0f804ba107905
6998ae8 to 27171ceComparepietermees commented Apr 9, 2018
@BridgeAR@apapirovski@jasnell updated to emit connect on next tick and added a test |
27171ce to e9f09bdComparepietermees commented Apr 9, 2018
streamlined the commits |
mcollina left a 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.
LGTM
mcollina commented Apr 10, 2018
pietermees commented Apr 10, 2018
@mcollina the CI error seems to be that |
mcollina commented Apr 10, 2018
That's probably flaky. We can land this. For the flaky test, open an issue with the output of the failure if you can :). |
cjihrig commented Apr 10, 2018
No need to open a new issue. See #19903 |
pietermees commented Apr 10, 2018
@cjihrig sure that's the same issue? The tests seem to succeed, but the process keeps running: See https://ci.nodejs.org/job/node-test-commit-linux/17820/nodes=debian8-x86/console |
mcollina commented Apr 10, 2018
@apapirovski are you ok for this to land? |
cjihrig commented Apr 10, 2018
addaleax commented Apr 10, 2018
@cjihrig Yup, exactly. I’m sorry for the inconvenience, I think this was worth it though… |
apapirovski commented Apr 10, 2018
Thanks for making the changes @pietermees — sorry for the back-and-forth. I think this should be ready to land. |
mcollina commented Apr 11, 2018
Landed in 4ac7753...2852521 |
PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
PR-URL: nodejs#19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
PR-URL: nodejs#19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
Backport-PR-URL: #20456 PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
Backport-PR-URL: #20456 PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
Backport-PR-URL: #20456 PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
Backport-PR-URL: #20456 PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
Backport-PR-URL: #20456 PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
Backport-PR-URL: #20456 PR-URL: #19842 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
grantila commented Aug 20, 2020
This seems to till be an issue in Node 12. I have it working on 10 and 14, but it doesn't work for me in 12. I'm digging through Node.js code to see what could potentially cause 12 to really break when 10 and 14 works, and I find weird things, undocumented. What is this (on master): Lines 1570 to 1571 in 2e6c3e2
These two options, |
grantila commented Aug 20, 2020
Never mind, this is fixed by #33343 |
Resolves#19839
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes