| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Review requested:
|
Sorry, something went wrong.
|
Good work! |
Sorry, something went wrong.
|
The problematic parser->current_buffer_.IsEmpty() check is a speed hack; it's explicitly documented as such. Adding a hack to work around a hack is not a good idea. My suggestion: remove current_buffer_. That simplifies the parser and makes it re-entrant again. Worry about performance afterwards. I speculate the hit won't be so bad, and can probably be fixed by doing the bookkeeping in JS land. |
Sorry, something went wrong.
|
@bnoordhuis Are you suggesting to remove that just in Execute, isn't it? |
Sorry, something went wrong.
|
current_buffer_ is used to thread through the buffer from a parser.execute(buffer) call from JS through C++ to the JS callback parser[kOnBody] = parserOnBody(buffer, start, len) { /* ... */ }. That threading through isn't necessary. Just set parser.buffer = buffer before calling parser.execute(buffer) and the callback can access it as this.buffer. Node can short-circuit and pass data directly from libuv to the callback without going through parser.execute(buffer) first but the callback can detect that by doing buffer = this.buffer ?? buffer. OnStreamRead()should be modified to create a new buffer instead of reusing current_buffer_. In theory that's a performance hit but I expect it's a wash because the callback no longer needs to call buffer.slice(). If I had infinite free time, I'd rewrite the parser to get rid of C++ -> JS callbacks and just return parse info. It'd get rid of so much complexity and inefficiency. |
Sorry, something went wrong.
|
Actually I was able to remove the current_buffer_ at all and apparently nothing changes. Local<Object> current_buffer_ = scope.Escape(Buffer::Copy(
env()->isolate(),
current_buffer_data_,
current_buffer_len_).ToLocalChecked());
Do you see any problem in this? |
Sorry, something went wrong.
|
@addaleax @bnoordhuis I've sent my latest version which removes current_buffer_ and thus also removes needs for all the suggestion Anna asked about. Can you please take a look again? |
Sorry, something went wrong.
|
@bnoordhuis I applied your changes (plus few additional required changes). How does it look now? |
Sorry, something went wrong.
|
Is there a reason you didn't update lib/_http_common.js? You don't need to slice anymore, or pass the start and len arguments. |
Sorry, something went wrong.
|
@bnoordhuis The answer is obvious: I forgot. X°°°D Done now! |
Sorry, something went wrong.
There was a problem hiding this comment.
Nice, good work!
@addaleax I'll go ahead and dismiss your review. Looks like all actionable feedback's been addressed.
Sorry, something went wrong.
|
@bnoordhuis The last item would be to try to test it without using the parser directly. I'll give it a try today but this can go out without as well. Done! |
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
wow, when a PR fixes a bug and reduces code, it's doing something right.
Sorry, something went wrong.
|
Thanks sir :) |
Sorry, something went wrong.
Sorry, something went wrong.
|
@nodejs/http Can anybody reapprove this so I can land it? |
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
|
Hello @ShogunPanda Thanks for your work ! |
Sorry, something went wrong.
|
@j-catania It was merged in main, which means it will be available in the next 18 release, I think 18.5.0. Not sure it will be backported. |
Sorry, something went wrong.
|
Is there a way to help see this backported to 16.x? This bug is really biting us as we are doing file uploads, and the 18 LTS release is still ~4 months off so upgrading isn't an option for us, and that we expect surrounding infra will take a few months to add 18 support after it releases. |
Sorry, something went wrong.
@nodejs/tsc Can we do this? What is the policy about backporting? |
Sorry, something went wrong.
|
node/doc/contributing/backporting-to-release-lines.md Lines 19 to 25 in 7bf50bc |
Sorry, something went wrong.
Standard policy is:
|
Sorry, something went wrong.
|
Thanks both. |
Sorry, something went wrong.
|
If the commit lands cleanly on v16.x-staging, there's no need for a backport PR: node/doc/contributing/backporting-to-release-lines.md Lines 11 to 17 in 7bf50bc If a backport PR is necessary, you don't need to wait two weeks for opening it, but the LTS team won't land it until it's been on a Current version for at least two weeks. |
Sorry, something went wrong.
|
I see. |
Sorry, something went wrong.
|
No, someone from @nodejs/lts will (try to) do it when preparing the next release, or leave a comment here if there's a conflict. |
Sorry, something went wrong.
PR-URL: nodejs/node#43369 Fixes: nodejs/node#39671 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
| Back | FazBrowse Home | New Git URL |
This PR fixes an edge case in which Parser::Execute is called within the callback of one of its events.
Fixes: #39671