Uh oh!
There was an error while loading. Please reload this page.
src: do not reuse HTTPParser - #25094
Conversation
368187e to
5d9eebdComparemmarchini
commented
Dec 17, 2018
cc @nodejs/async_hooks @nodejs/diagnostics |
Drieger
commented
Dec 17, 2018
The problem with linter is that |
Just write: or alternatively use |
Flarna
commented
Dec 17, 2018
If I understand this correct the resource type is still Wouldn't it better to have two resource types instead? |
Perhaps the commit message could be more clear. 'do not reuse HTTPParser' makes it sound as if parser objects are not being reused, when in fact it's the associated async resource that's no longer being reused (if I understand correctly). |
Uh oh!
There was an error while loading. Please reload this page.
AndreasMadsen
left a comment
There was a problem hiding this comment.
Thanks for spending time on this.
Uh oh!
There was an error while loading. Please reload this page.
Drieger
commented
Dec 19, 2018
@Flarna maybe we could use |
Flarna
commented
Dec 19, 2018
Not sure here; maybe prefix with |
There was a problem hiding this comment.
Isn't this reusing the IncomingMessage constructor function instead of the concrete instance? If I understand the code correct the IncomingMessage instance is created in parserOnHeadersComplete.
If I'm correct I wonder why the dedicated test-httparser-reuse.js is not detecting this.
There was a problem hiding this comment.
@Drieger This one is still open and if I'm correct this is a no go.
There was a problem hiding this comment.
You are right @Flarna I'll investigate this more in depth.
There was a problem hiding this comment.
@FlarnakIncomingMessage is really a function as you said. I fixed the test to catch this.
I will also create a new object to be the resource for the server. Some other changes will be necessary as well. I will update the PR as soon as I this is working.
Drieger
commented
Jan 9, 2019
@Flarna I just updated the PR, adding two new providers HTTPINCOMINGMESSAGE and HTTPCLIENTREQUEST, could you take a look if that is what you had in mind? I'll check why is the CI failing. |
Flarna
commented
Jan 9, 2019
Yes, looks ok. I think an alternative would be I would love if others give also their comments on these names as they are actually public API (even it's just in experimental part). Is https://github.com/nodejs/node/blob/master/doc/api/async_hooks.md needs also some update once agreement on the names is reached. |
Drieger
commented
Jan 9, 2019
You are right, I think |
Drieger
commented
Jan 10, 2019
Fix test issues! /cc @mmarchini@mcollina@AndreasMadsen@richardlau@mscdex could you check again? What do you think about the naming suggested by @Flarna? |
Drieger
commented
Jan 14, 2019
I changed the resource in the Obs.: Documentation and commit message will be updated if everything is ok. |
There was a problem hiding this comment.
I think we should remove this parameter, or is it used somewhere else?
There was a problem hiding this comment.
Removed parameter and renamed the method.
mcollina
commented
Jan 17, 2019
mcollina
commented
Jan 19, 2019
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/288/ (again, the previous one errored). |
Drieger
commented
Mar 6, 2019
I think I addressed all previous comments, any other comments on this? @nodejs/diagnostics @nodejs/async_hooks |
I've tagged this semver-major because of the impact it can have on async_hooks users. It's not technically required because async_hooks are experimental, but they are widely used. |
Change resource being used, previously HTTParser was being reused. We are now using IncomingMessage and ClientRequest objects. The goal here is to make the async resource unique for each async operatio Refs: #24330 Refs: nodejs/diagnostics#248 Refs: #21313 Co-authored-by: Matheus Marchini <mat@mmarchini.me> PR-URL: #25094 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Flarna
commented
Apr 22, 2019
I hoped that this one fixes #26961 but actually it didn't. I think that |
Fix some issues introduced/not fixed via #25094: * Init hook is not emitted for a reused HTTPParser * HTTPParser was still used as resource in init hook * type used in init hook was always HTTPINCOMINGMESSAGE even for client requests * some tests have not been adapted to new resource names With this change the async hooks init event is emitted during a call to Initialize() as the type and resource object is available at this time. As a result Initialize() must be called now which could be seen as breaking change even HTTPParser is not part of documented API. It was needed to put the ClientRequest instance into a wrapper object instead passing it directly as async resource otherwise test-domain-multi fails. I think this is because adding an EventEmitter to a Domain adds a property 'domain' and the presence of this changes the context propagation in domains. Besides that tests still refering to resource HTTPParser have been updated/improved. Fixes: #27467Fixes: #26961 Refs: #25094 PR-URL: #27477 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Fix some issues introduced/not fixed via #25094: * Init hook is not emitted for a reused HTTPParser * HTTPParser was still used as resource in init hook * type used in init hook was always HTTPINCOMINGMESSAGE even for client requests * some tests have not been adapted to new resource names With this change the async hooks init event is emitted during a call to Initialize() as the type and resource object is available at this time. As a result Initialize() must be called now which could be seen as breaking change even HTTPParser is not part of documented API. It was needed to put the ClientRequest instance into a wrapper object instead passing it directly as async resource otherwise test-domain-multi fails. I think this is because adding an EventEmitter to a Domain adds a property 'domain' and the presence of this changes the context propagation in domains. Besides that tests still refering to resource HTTPParser have been updated/improved. Fixes: #27467Fixes: #26961 Refs: #25094 PR-URL: #27477 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Avoid that destroy hook is invoked twice - once via `Parser::Free()` and once again via `Parser::Reinitialize()` by clearing the async_id in `EmitDestroy()`. Partial backport of nodejs#27477, a full backport would require also nodejs#25094 which has a dont-land-on-v10.x label on it. Fixes: nodejs#26961
Avoid that destroy hook is invoked twice - once via `Parser::Free()` and once again via `Parser::Reinitialize()` by clearing the async_id in `EmitDestroy()`. Partial backport of #27477, a full backport would require also #25094 which has a dont-land-on-v10.x label on it. Fixes: #26961 Backport-PR-URL: #27986 PR-URL: #27477 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Avoid that destroy hook is invoked twice - once via `Parser::Free()` and once again via `Parser::Reinitialize()` by clearing the async_id in `EmitDestroy()`. Partial backport of #27477, a full backport would require also #25094 which has a dont-land-on-v10.x label on it. Fixes: #26961 Backport-PR-URL: #27986 PR-URL: #27477 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Change resource being used, previously HTTParser was being reused. We are now using IncomingMessage and ClientRequest objects. The goal here is to make the async resource unique for each async operation
Refs: #24330
Refs: nodejs/diagnostics#248
Refs: #21313
Co-authored-by: Matheus Marchini matheus@sthima.com
I continued @mmarchini work on #24330 and finished what was missing. I also added a test based on @AndreasMadsen comment nodejs/diagnostics#248 (comment)
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes