node-formidable / node-formidable/formidable
Attaching 'data' listeners immediately
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 7.2k
- Forks
- 689
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 2
Description
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: https://github.com/node-formidable/formidable/blob/d0fbec13edc8add54a1afb9ce1a8d3db803f8d47/src/Formidable.js#L233
See https://github.com/microsoft/playwright/issues/35823#issuecomment-2847667026 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/Formidable.js around the current listener attachment after writeHeaders, then compare the reported behavior with Formidable v1. Reproduce the async-hop case where another consumer receives data, and verify that formidable can still parse the complete request body when listeners are attached earlier.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100