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

undici collaboration #1247

Open
ronag opened this issue Aug 16, 2021 · 10 comments
Open

undici collaboration #1247

ronag opened this issue Aug 16, 2021 · 10 comments

Comments

@ronag
Copy link

ronag commented Aug 16, 2021

We are currently working with implementing fetch in https://github.com/nodejs/undici which is being considered for inclusion in Node core.

I was hoping that maybe we could combine some of our efforts with node-fetch. We are already using some of the tests from node-fetch (thank you and we have of course added reference and LICENSE from node-fetch).

undici is looking for what I believe is a more strict interpretation of the spec at the cost of ergonomics. I was thinking about whether it would be an idea to suggest whether node-fetch would consider using undici/fetch as it's base implementation while providing a more node friendly interface? e.g. support for more FormData, Headers, Blob, File implementations, better node stream support etc... while keeping the fetch spec parts in undici?

@ronag ronag changed the title undici undici collaboration Aug 16, 2021
@ronag
Copy link
Author

ronag commented Aug 16, 2021

I've made some similar attempts in regards to https://github.com/github/fetch.

@ronag
Copy link
Author

ronag commented Aug 16, 2021

I think a blocker here is node 16+ requirement of undici

@jimmywarting
Copy link
Collaborator

Some form of collaboration with undici would be cool. The node 16+ would be a blocker doe. might just as well push for implementing undici into node core instead. and let undici and node-fetch takes it corse to become obsolete in the feature?

whether node-fetch would consider using undici/fetch as it's base implementation while providing a more node friendly interface?

When whatwg streams landed in nodejs we shifted the focus from being a tiny bit lightweight and having some few node specific feature. To be more strict/spec compatible. So whatever code you write can for sure be used with Browser, Deno, node's core fetch, undici and node-fetch

That have lead to:

  • we might adding support for body.formData() after v3 lands
  • deprecate body.buffer() - (and remove it in v4)
  • deprecate support for old non spec'ed form-data and replace it with a spec compatible instead - (and remove it in v4)
  • the v4 might depend on web-stream-polyfill to ship a whatwg stream in res.body

while providing a more node friendly interface?

Much less so now when whatwg streams landed in NodeJS, Now we are more strict.

Support for more FormData, Headers, Blob, File implementations

This is our goal to be spec compatible and more cross compatible with other fetch implementations in other environments. My impression of undici is that you still lack support for FormData and Blobs still? I haven't used or taken a look at your repo for a while.

@ronag
Copy link
Author

ronag commented Aug 16, 2021

We are just about to land support for formdata (Pr is open). Blob support has already landed.

@jimmywarting
Copy link
Collaborator

We are just about to land support for formdata (Pr is open). Blob support has already landed.

Ok, it wasn't the last time i checked.

@Richienb
Copy link
Member

Whether fetch does get implemented Node.js or more strictly in undici, the goal of node-fetch would change to backporting it to the oldest Node version still in maintenance until that becomes one that doesn't require a ponyfill. At that point, if the community still relied on the now-legacy streams and buffers, then node-fetch may want to backport that too like suggested above.

@jimmywarting
Copy link
Collaborator

jimmywarting commented Aug 16, 2021

Yup, node-fetch would be more of a polyfill instead. until it's no longer needed

@ronag
Copy link
Author

ronag commented Aug 17, 2021

Sounds reasonable. Just wanted to reach out and see if there was anything we can do. Feel free to close this.

@jimmywarting
Copy link
Collaborator

if you break out some stuff to separate packages that can be shared across node-fetch and undici (and is still compatible with node v12.20) then we could use the same stuff.

Would be grate to agree upon some packages so there isn't duplicated code for two similar things
For instance, you implemented FormData yourself instead of depending on a existing userland package

@jimmywarting
Copy link
Collaborator

jimmywarting commented Jan 14, 2022

@ronag the kind of collaboration i would like to have now is for the smaller core pieces that builds up fetch for what it's today to be shipped to NodeJS core first

I'm talking about

  1. First seeing a File class being implemented into core (Implement File class nodejs/node#39015)
  2. Then a way for getting a File instant being backed up by the filesystem (Getting Files backed up by the filesystem nodejs/node#37340)
    Files and blob's are pretty useless if they can't be backed up by the filesystem and that's why we can't depend on buffer.Blob fully
  3. When that is done i wish to see support for FormData to be implemented into core (Adding HTML form data handling to core nodejs/node#38943)

This 3 could be considerable easy to ship to nodes core first, without having any logic associated to the fetch specification at all. it can also be easliy sharable between node-fetch and undici

We would like to slowly but safely remove bits and pieces one bit at the time so we can depend on core features instead.

would be nice to be able to stop depending on fetch-blob and formdata-polyfill for example...

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

No branches or pull requests

3 participants