Repository navigation
Conversation
Adding failing coverage that shows FilesLimitError is replaced by ERR_STREAM_PREMATURE_CLOSE when the multipart body is fully buffered (fastify.inject or http end(buffer)) before parts are consumed. Existing filesLimit tests still pass because they stream via form.pipe. Co-authored-by: Cursor <cursoragent@cursor.com>
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds failing regression tests only (no fix). CI is expected to be red until the issue is fixed.
On
@fastify/multipart@10.1.1, exceedinglimits.fileswhile consuming parts withpart.toBuffer()often throwsERR_STREAM_PREMATURE_CLOSE(Premature close) instead ofFilesLimitError(FST_FILES_LIMIT) when the request body is fully buffered up front.This appears to be an unintended side effect of the GHSA-vmph-573x-85f6 fix that stopped clearing
currentFileinonError:filesLimitcleanup now destroys the in-flight part stream, racing ahead of theFilesLimitErrordelivered on the async iterator.Passes on 10.1.0 / fails on 10.1.1
npm test -- test/multipart-files-limit-buffered-body.test.jsWhy existing filesLimit tests still pass
They use
form.pipe(req), which streams the body slowly enough that the previous part is usually fully consumed beforefilesLimitfires. The regression shows up with:fastify.inject({ payload: form.getBuffer() })http.request(...); req.end(form.getBuffer())Both are common in apps and Fastify tests.
Related
Will also open an issue with a write-up; this PR is the executable repro.