undici
undici copied to clipboard
Help for users to migrate from node-fetch to native fetch in V18
This would solve...
It would simplify for me, as a plain old user, to not have to import node-fetch when node supposedly should have a "native" version of fetch already.
Just make it work for the users or at least make a FAQ about node-fetch vs fetch (undici) how users can get feature parity.
The implementation should look like...
You have considered users and workflows.
I have also considered...
looking at various other bug reports and such here. Yet, I still have to import node-fetch because I cannot get Node v18 fetch to not throw me an error. The only workaround so far is to import node-fetch. So why did you import fetch into node? For me that's just added waste in V18 that I cannot use.
Trace: TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11457:11)
at async processor (file:///home/root/omnicoder/docker/swayer/src/processor.mjs:127:20)
at async file:///home/root/omnicoder/docker/swayer/src/app.js:57:22 {
cause: HeadersTimeoutError: Headers Timeout Error
at Timeout.onParserTimeout [as callback] (node:internal/deps/undici/undici:9647:32)
at Timeout.onTimeout [as _onTimeout] (node:internal/deps/undici/undici:7948:17)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7) {
code: 'UND_ERR_HEADERS_TIMEOUT'
}
}
Related to
Related to existing open issues here:
- https://github.com/nodejs/undici/issues/1865
- https://github.com/nodejs/undici/issues/1919
- DNS resolution to IPv6 address is different (yet, not acknowledged by Node.js as a problem) https://github.com/nodejs/undici/issues/1413
make a FAQ about node-fetch vs fetch (undici) how users can get feature parity.
Would you like to send in a PR? Please remember that the maintainers are people and calling our work a "waste" is not polite.
The node.js org decided to import undici as a part of the standard node.js library. Why? To save time for undici developers, as they now did not need to import it via npm install? Presuably it was imported with an ambition larger than that, to unify the 3rd party users and cater to all fetch use cases. If so, the job is only half done, as we node-fetch users are still clueless about how to reach feature parity with the old 3rd party node-fetch library. The net effect so far, for me as a node-fetch user, is that now I have to install two fetch libraries, and I cannot opt-out from the undici package because it is soldered into the platform.
PS. This is not twitter.
Why? To save time for undici developers, as they now did not need to import it via npm install?
No. Fetch was added because it was one of -- if not the most -- requested feature to be added to node.
to unify the 3rd party users and cater to all fetch use cases.
Yes, the distinction here is fetch use cases, not node-fetch. Node-fetch makes large deviations from the spec (which are documented), whereas undici intends to implement a nearly spec compliant fetch (the differences from the spec are also documented). Following both documents, you should be able to discern the differences between the two libraries.
is that now I have to install two fetch libraries, and I cannot opt-out from the undici package because it is soldered into the platform.
Since undici is bundled in node, you only need to install one other library if you choose to use node-fetch.
Regardless, your issue is that the server did not send the complete headers within 5 minutes (assuming you are using the default undici configuration). This timeout is identical to the one that Chrome uses. If this is expected, you can configure an undici Agent to increase the time.