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

Doesn't play nice with node v18 undici fetch #533

Open
wmertens opened this issue Apr 29, 2022 · 3 comments
Open

Doesn't play nice with node v18 undici fetch #533

wmertens opened this issue Apr 29, 2022 · 3 comments

Comments

@wmertens
Copy link

In Node 18 the standards-compliant undici fetch is available, and it accepts Node's Readable Stream as a body as well as the standard Web Streams.

The problem is that new FormData() doesn't return an object that is recognized as a Readable.

Workaround:

import {PassThrough} from 'stream'
// ...
const pt = new PassThrough()
formData.pipe(pt)
fetch(url, {
  // ...
  body: pt
})

You can test the problem in Node 18 by running the following, which will throw:

import {Readable} from 'stream'
// ...
Readable.toWeb(formData)

Probably Readable needs to be in the prototype chain?

@jimmywarting
Copy link

instead of using form-data use the FormData provided by nodejs/undici itself

@wmertens
Copy link
Author

@jimmywarting and forego all the nice features?

@jimmywarting
Copy link

like what features?

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

2 participants