http2: implement ref() and unref() on sessions#17620
http2: implement ref() and unref() on sessions#17620kjin wants to merge 6 commits intonodejs:masterfrom
Conversation
addaleax
left a comment
There was a problem hiding this comment.
I saw this comment made by @addaleax about
uv_prepare_t, but I don't really understand it. To me, this code change seems sufficient, but maybe I'm missing something.
The code has changed since then. :)
Should
ClientHttp2Sessioninstances beunrefd by default?
I don’t think so; if you have an active network connection, you usually want that to keep the event loop alive.
Should these be available on
ServerHttp2Sessionobjects as well? (my thought is no)
Why not? :)
Should calling
ref/unrefbe a no-op after the session has been destroyed, or could it return an error?
It seems doing nothing is what net.Socket does, so I’d go with that? I think that’s what this code already does, right? 👍
doc/api/http2.md
Outdated
There was a problem hiding this comment.
Can you use added: REPLACEME here? That way it gets picked up automatically by the release tooling :)
lib/internal/http2/core.js
Outdated
There was a problem hiding this comment.
Can you also check whether typeof this[kSocket].ref === 'function'? HTTP/2 supports any stream as the underlying socket, so .ref might not be present at that point.
The test file that checks that is test/parallel/test-http2-generic-streams.js, if you want to extend that – I think calling .ref() there would crash right now?
I thought Seems like it's worthwhile to ensure |
|
@kjin I think those are different things – |
|
Yep, I understand that Currently |
826acba to
8714f6f
Compare
|
@addaleax Thanks for the feedback so far, I've updated the PR to make |
|
This should wait to land until after #17406, as is may need to be updated based on those changes. |
Hmm, but if the session isn't transporting any data (just kept open because of HTTP/2 semantics) I don't see a good reason why it should keep the event loop alive. |
lib/internal/http2/core.js
Outdated
There was a problem hiding this comment.
Why not just this[kSocket].ref? That’s what’s being called anyway, right?
There was a problem hiding this comment.
For generic duplex streams this[kSocket] is a JSStreamWrap object, which doesn't have a handle.ref field.
Actually, this makes me think that net.Socket itself should be checking that _handle.ref is a function, rather than here. I'll add a trailing commit that does so, we can drop it if there is already a good rationale for not checking in net.
|
@TimothyGu This is just calling through to the underlying socket, the HTTP2 session itself won’t keep anything open |
f601654 to
0346126
Compare
0346126 to
c64f6b1
Compare
|
@jasnell @addaleax I've rebased the PR on master. The only conflict was in the docs, since I moved I can understand if it's not in the scope of this PR to move the |
79739eb to
f29e6a7
Compare
f29e6a7 to
b3d2513
Compare
PR-URL: #17620 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
|
landed in 120ea9b |
PR-URL: nodejs#17620 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Backport-PR-URL: #18050 PR-URL: #17620 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Backport-PR-URL: #18050 PR-URL: #17620 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
|
Thanks for the ping, not sure why this hasn't been backported yet. |
Backport-PR-URL: nodejs#18050 PR-URL: nodejs#17620 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Backport-PR-URL: #18050 Backport-PR-URL: #20456 PR-URL: #17620 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Fixes #16617
This is my stab at adding
refandunrefonClientHttp2Sessioninstances. It seems mostly straightforward, but there were a few questions I had in mind about this code change:ClientHttp2Sessioninstances beunrefd by default?ServerHttp2Sessionobjects as well? (my thought is no)ref/unrefbe a no-op after the session has been destroyed, or could it return an error?I saw this comment made by @addaleax about
uv_prepare_t, but I don't really understand it. To me, this code change seems sufficient, but maybe I'm missing something.Also, I updated the docs to separate
ClientHttp2SessionfromHttp2Session... which seemed to make sense considering that this distinction is present even in the codebase.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
http2