Skip to content
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

fetch: avoid async iteration when request.body is null #1303

Merged
merged 2 commits into from Mar 28, 2022
Merged

fetch: avoid async iteration when request.body is null #1303

merged 2 commits into from Mar 28, 2022

Conversation

RafaelGSS
Copy link
Member

@RafaelGSS RafaelGSS commented Mar 28, 2022

It avoids treating request.body as an async iterator when it's null.

In my local tests, it increases the performance by almost 10%.

@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2022

Codecov Report

Merging #1303 (211bab4) into main (65feb05) will increase coverage by 0.00%.
The diff coverage is 61.53%.

@@           Coverage Diff           @@
##             main    #1303   +/-   ##
=======================================
  Coverage   94.16%   94.16%           
=======================================
  Files          45       45           
  Lines        4112     4114    +2     
=======================================
+ Hits         3872     3874    +2     
  Misses        240      240           
Impacted Files Coverage Δ
lib/fetch/index.js 80.33% <61.53%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65feb05...211bab4. Read the comment docs.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a unit test?

@mcollina
Copy link
Member

lgtm

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to think about this

@ronag ronag self-requested a review March 28, 2022 13:49
Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelGSS I slightly modified your PR. Hope you don't mind. LGTM. If you approve we can merge.

Copy link
Member Author

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems there are some pushes from other branches. Overall LGTM.

lib/fetch/util.js Outdated Show resolved Hide resolved
lib/mock/mock-interceptor.js Outdated Show resolved Hide resolved
@ronag ronag merged commit a211b18 into nodejs:main Mar 28, 2022
KhafraDev pushed a commit to KhafraDev/undici that referenced this pull request Jun 23, 2022
* fetch: avoid iteration when request.body is null

* slightly simplify

Co-authored-by: Robert Nagy <ronagy@icloud.com>
metcoder95 pushed a commit to metcoder95/undici that referenced this pull request Dec 26, 2022
* fetch: avoid iteration when request.body is null

* slightly simplify

Co-authored-by: Robert Nagy <ronagy@icloud.com>
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
* fetch: avoid iteration when request.body is null

* slightly simplify

Co-authored-by: Robert Nagy <ronagy@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants