Skip to content

Use alternatives to formData from undici for processing form data #331

Open
@timtucker

Description

@timtucker

Undici v5 is EOL as of April 30, 2025.

In v6, the formData() method on responses was marked as deprecated.

It's still there in v7, but presumably will be dropped in a future release.

Azure Functions should use the approach suggested by Undici:
https://github.com/nodejs/undici/blob/v6.21.1/types/fetch.d.ts

/**
   * @deprecated This method is not recommended for parsing multipart/form-data bodies in server environments.
   * It is recommended to use a library such as [@fastify/busboy](https://www.npmjs.com/package/@fastify/busboy) as follows:
   *
   * @example
   * ```js
   * import { Busboy } from '@fastify/busboy'
   * import { Readable } from 'node:stream'
   *
   * const response = await fetch('...')
   * const busboy = new Busboy({ headers: { 'content-type': response.headers.get('content-type') } })
   *
   * // handle events emitted from `busboy`
   *
   * Readable.fromWeb(response.body).pipe(busboy)
   * ```
   */
  readonly formData: () => Promise<FormData>

This issue goes into the reasons why they suggest using the approach above:
nodejs/undici#2890

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions