Skip to content

Attaching 'data' listeners immediately #1011

Open
@mxschmitt

Description

@mxschmitt

Support plan

  • Which support plan is this issue covered by? (Community, Sponsor, Enterprise): Community
  • Currently blocking your project/work? (yes/no): yes
  • Affecting a production system? (yes/no): OSS - we can't update to formidable v3

Context

  • Node.js version: 22
  • Release Line of Formidable (Legacy, Current, Next): Current
  • Formidable exact version: v3
  • Environment (node, browser, native, OS): Node.js/macOS
  • Used with (popular names of modules):

What are you trying to achieve or the steps to reproduce?

In formidable v2/v3 the parsing is async and the 'data' handlers are attached not directly. This causes an issue that if you have multiple async things happening after the request was started other consumers might consume the buffered 'data' chunks. Then formidable is not able to parse the request anymore since it receives only a part of it.

An easy fix for that would be to attach the handlers earlier - at the beginning when calling parse.

Currently they are attached after writeHeaders:

await this.writeHeaders(req.headers);

See microsoft/playwright#35823 (comment) for more information. We would appreciate if this could considered since it breaks our use-case and potentially also other customers with async/await hops.

What was the result you got?

When there is an async hop which is consuming 'data' as well, formidable is not able to parse the request body.

What result did you expect?

It works like in formidable v1 - there the parsing was sync.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions