fastify / fastify/fastify-multipart
FST_FILES_LIMIT not being raised when files limit is exceeded
- Dominant language
- JavaScript
- Stars
- 539
- Forks
- 126
- PR merge metrics
- No merged PRs in 30d
Description
### Prerequisites
- [x] I have written a descriptive issue title
- [x] I have searched existing issues to ensure the bug has not already been reported
### Fastify version
5.12.0
### Plugin version
10.1.1
### Node.js version
26.7
### Operating system
macOS
### Operating system version (i.e. 20.04, 11.3, 10)
Tahoe 26.6.2
### Description
On `@fastify/multipart@10.1.1`, when a request exceeds `limits.files` and parts are consumed with `part.toBuffer()`, we're seeing:
- `code: 'ERR_STREAM_PREMATURE_CLOSE'`
- `message: 'Premature close'`
instead of:
- `FilesLimitError` / `code: 'FST_FILES_LIMIT'` / `statusCode: 413`
This worked on 10.1.0.
### Link to code that reproduces the bug
https://github.com/fastify/fastify-multipart/pull/641
### Expected Behavior
I expect to see FST_FILES_LIMIT if the file limit is exceeded.
Contributor guide
Research direction
Start with the reproducer linked in the issue, https://github.com/fastify/fastify-multipart/pull/641, using @fastify/multipart 10.1.1 and the stated Node.js environment. Exercise requests that exceed limits.files while consuming parts with part.toBuffer(), then verify that the result is FilesLimitError with code FST_FILES_LIMIT and statusCode 413 rather than ERR_STREAM_PREMATURE_CLOSE.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100