Skip to content

Conversation

@katayama8000
Copy link
Contributor

@katayama8000 katayama8000 commented Dec 21, 2024

Internal refactoring: Replace node-fetch with undici

Motivation
The primary objective of this refactoring is to modernize our HTTP request stack and align the library with the evolving Node.js ecosystem standards.

  1. Alignment with Node.js Standards: undici is the high-performance HTTP client that powers the native fetch implementation in modern Node.js versions (v18+). By migrating to undici, we transition from a third-party polyfill (node-fetch) to the platform's underlying standard, ensuring better long-term maintainability and performance.
  2. Dependency Simplification: While this swaps one dependency for another, undici provides a more "native" and foundational choice for the Node.js runtime. Furthermore, this change allowed us to remove msw from our development dependencies by leveraging undici's built-in mocking capabilities.

@katayama8000 katayama8000 requested a review from a team as a code owner December 21, 2024 15:19
@katayama8000 katayama8000 requested review from douglowder and removed request for a team December 21, 2024 15:19
@katayama8000
Copy link
Contributor Author

#71

@katayama8000
Copy link
Contributor Author

katayama8000 commented Dec 21, 2024

@douglowder Could you review this?

@nicknovitski
Copy link
Member

I've fixed our test workflow to run on pull requests, so if you update your branch, all those required statuses will pass:

Screenshot 2024-12-21 at 12 09 51 PM

Sorry that we didn't have that set up already, thanks again for the contribution!

Copy link
Contributor

@douglowder douglowder left a comment

Choose a reason for hiding this comment

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

See inline comments

@joaoschaab
Copy link

Any updates on this one?

@katayama8000
Copy link
Contributor Author

katayama8000 commented Apr 27, 2025

@joaoschaab no.

@katayama8000
Copy link
Contributor Author

katayama8000 commented Jan 4, 2026

@douglowder @nicknovitski @ide
After some time, I have successfully removed node-fetch.
Can you review this?

Copy link
Contributor

@vonovak vonovak left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
I have taken a quick look, I'll still need to take a better look later.

For now please:

  • kindly accept the suggestion, it simplifies the code a bit
  • fill out the PR description - what's the motivation for the change, why so many changes to the test suite were needed, and anything else that comes to your mind. Anybody from the community who visits the PR should be able to get read some reasoning on this.
    Thank you!

@katayama8000
Copy link
Contributor Author

Thanks for the PR! I have taken a quick look, I'll still need to take a better look later.

For now please:

  • kindly accept the suggestion, it simplifies the code a bit
  • fill out the PR description - what's the motivation for the change, why so many changes to the test suite were needed, and anything else that comes to your mind. Anybody from the community who visits the PR should be able to get read some reasoning on this.
    Thank you!

#116 (comment)

I filled out the PR description. Could you review it again? @vonovak

@katayama8000 katayama8000 requested a review from vonovak January 14, 2026 11:19
Copy link
Member

@nicknovitski nicknovitski left a comment

Choose a reason for hiding this comment

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

I understand the need for the changes to the tests: msw doesn't work with an explicitly imported undici, but undici has a built-in mocking feature.

On the subject of documentation, this would be a breaking change, since the agent option now is an undici agent, not an http agent.

@katayama8000 katayama8000 changed the title Remove node-fetch Replace node-fetch to undici Jan 15, 2026
@katayama8000
Copy link
Contributor Author

katayama8000 commented Jan 15, 2026

I understand the need for the changes to the tests: msw doesn't work with an explicitly imported undici, but undici has a built-in mocking feature.

On the subject of documentation, this would be a breaking change, since the agent option now is an undici agent, not an http agent.

@nicknovitski
Thanks for the review.
Is there any docmentation I should fix or Does this mean we need a major version bump?

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