-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
[v8.x] http: attach reused parser to correct domain #25459
[v8.x] http: attach reused parser to correct domain #25459
Conversation
Reused parsers can be attached to the domain that corresponds to the active domain when the underlying socket was created, which is not necessarily correct. Instead, we attach parsers to the active domain if there is one when they're reused from the pool. Refs: nodejs#25456
@misterdjules sadly an error occured when I tried to trigger a build :( |
/cc @nodejs/domains |
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 not having an easy time figuring out why adding the parser
to the current domain fixes things, and more importantly, why the domain module’s init()
hook does not already add the parser to the domain?
// Since this request throws before its callback has the chance | ||
// to be called, we mark the test as failed if this callback is | ||
// called. | ||
process.exit(1); |
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.
If the only reason for this is to mark the test as failed, I’d prefer setting process.exitCode = 1
and letting the test finish on its own (here and elsewhere) – it might also be nice to get some output from the test in those cases?
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.
Sure, i'll do both!
const agent = new http.Agent({ | ||
// keepAlive is important here so that the underlying socket of all requests | ||
// is reused and tied to the same domain. | ||
keepAlive: true |
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.
Can we have an assertion that checks that the connection is the same for all requests?
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.
Good point!
Instead of an assertion, which can throw an exception and thus trigger a different code path with regards to domain error handling that would make this test really difficult to write, do you mind if, as for other failure cases in this test, we set the exit code to 1?
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.
@misterdjules Yes, that sounds good to me as well :)
Adding the parser to the current domain fixes things because by doing that, all events emitted on that parser will enter that domain. This is equivalent to what's done in node >= 10.x by the domain module's async hooks.
This PR is targeted at the v8.x-staging branch where the domain module doesn't use async hooks to track resources lifecycle. The issue referenced by this PR specifically states:
|
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.
Thanks, I missed that this targets v8.x.
@addaleax Pushed a new commit that I think addresses your comments, thanks for the help! |
I just noticed something else that seems to be an issue, but I think may be orthogonal to the problem that this PR is addressing: when the It means that if an error is thrown and not caught when the parser's Again, I think this is orthogonal to the issue that this PR is fixing, so I'll open a separate issue to discuss that. |
FWIW, issue opened at #25505. |
We are planning one last semver-minor with 8.x, so that would be a last chance to get this in. Does the bug only occur on that branch? |
It occurs on the v8.x branch and previous branches like v6.x, but it doesn't occur on v10.x and "later" branches. |
@MylesBorins I would think that at the very least we'd want to run citgm for these changes, is that something that will be done for the whole upcoming 8.x release, or should we do it separately for this change? |
@misterdjules we do run it on every release, but if you think this specific change should be checked I'm 100% in support https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1717/ |
@MylesBorins Excellent, thank you! I'll watch the results of that job. |
@MylesBorins It seems that there's a lot of errors like:
in https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1717/ from tape, so maybe we'll get meaningful results only when we run the citgm on an actual release build? |
Hello can someone provide an update on when this PR will be merged? Thanks! -Scott |
Do you know when that is planned (if planned) and whether this change would make it to that release? I've been following nodejs/Release#405 where you wrote:
Is it still what you have in mind for the next 8.x release? |
another CI run https://ci.nodejs.org/job/node-test-pull-request/20451/ Late march is the plan for 8.x semver-minor, it will definitely be happeningg |
CI is green. Two failues in CITGM I don't recognize if you could take a look |
@MylesBorins I ran the following for both
with |
got and ava are now known CITGM failures and not specific to this PR. |
Reused parsers can be attached to the domain that corresponds to the active domain when the underlying socket was created, which is not necessarily correct. Instead, we attach parsers to the active domain if there is one when they're reused from the pool. Refs: #25456 PR-URL: #25459 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Landed on v8.x-staging |
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes[ ] documentation is changed or addedReused parsers can be attached to the domain that corresponds to the
active domain when the underlying socket was created, which is not
necessarily correct.
Instead, we attach parsers to the active domain if there is one when
they're reused from the pool.
Refs: #25456