Skip to content

undici parses FormData bodies incorrectly #2890

@KhafraDev

Description

@KhafraDev

The parsing should be synchronous. The spec makes it abundantly clear that you buffer the body in memory and then parse it, which we do for every other body mixin. It also doesn't make much sense for us to parse the body asynchronously only for us to buffer it into memory later on. It's not meant for server environments and we shouldn't give people a false sense of security.

  • It's also extremely slow
  • We also fail a large amount of WPTs regarding formdata parsing because of this.
  • There are a large number of hacks/workarounds for shortcomings of our current approach.
  • Every other platform (Deno, Webkit/bun, Chrome, and Firefox) parse it synchronously. I've previously posted proof of this in an issue but it'd be hard to track it down.

If someone wants to stream the formdata parsing:

const response = await fetch('https://formdata.idk.com')
const busboy = new Busboy({ headers: { 'content-type': response.headers.get('content-type') } })

Readable.from(response.body).pipe(busboy)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions