Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

FelixVaughan
Copy link
Contributor

This relates to...

#4066

Changes

Added section in documentation to highlight undici vs fetch differences and usecases

Status

@FelixVaughan
Copy link
Contributor Author

I'm not sure if this is what we want or if all the information is up to date, but I'm happy to iterate on this and make the necessary changes.

Here's a link of some of the sources I used:
https://blog.platformatic.dev/http-fundamentals-understanding-undici-and-its-working-mechanism
#3253
https://nodejs.org/en/learn/getting-started/fetch

README.md Outdated

**Cons:**
- Additional dependency to manage
- Larger bundle size if used in client-side code
Copy link
Member

Choose a reason for hiding this comment

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

This is not a thing, you should not be using either in client-side frontend code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the portion about client-side code. Let me know if I should scrap the point entirely

README.md Outdated
#### Use Built-in Fetch When:
- You want zero dependencies
- Building isomorphic code that runs in browsers and Node.js
- You need standard Web API compatibility
Copy link
Member

Choose a reason for hiding this comment

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

This point is incorrect, they offer the same (circa) level of web standard compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, updated.

README.md Outdated

1. **`undici.request()`** - Fastest, most efficient
2. **`undici.fetch()`** - Fast, with Web API compatibility
3. **Built-in `fetch()`** - Good performance, standard compliance
Copy link
Member

Choose a reason for hiding this comment

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

2 and 3 should be essentially identical

@FelixVaughan FelixVaughan requested a review from mcollina June 1, 2025 15:26
@rkdefra
Copy link

rkdefra commented Jun 2, 2025

👍 This extra detail is great!

@FelixVaughan FelixVaughan marked this pull request as ready for review June 2, 2025 15:38
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.

lgtm

@mcollina mcollina requested a review from KhafraDev June 3, 2025 15:19
@FelixVaughan
Copy link
Contributor Author

@mcollina can we land this?

@mcollina mcollina merged commit 9eb2a2f into nodejs:main Jun 14, 2025
29 of 31 checks passed
@github-actions github-actions bot mentioned this pull request Jun 26, 2025
- You want zero dependencies
- Building isomorphic code that runs in browsers and Node.js
- Simple HTTP requests without advanced configuration
- You're okay with the undici version bundled in your Node.js version
Copy link
Member

@styfle styfle Jun 27, 2025

Choose a reason for hiding this comment

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

I think this last bullet point isn’t quite right.

Because it’s not “your Node.js“ version but rather, the consumer’s Node.js version.

Like if you publish to npm, it could be running under any Node.js version that the user decides to execute.

Copy link
Member

Choose a reason for hiding this comment

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

@styfle can you send some updated text?

Copy link
Member

Choose a reason for hiding this comment

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

@mcollina I created PR #4319

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.

5 participants