Repository navigation
fix: ignore epilogue after closing multipart boundary - #229
Closed
kilisamemarisaaa wants to merge 2 commits into
Closed
kilisamemarisaaa wants to merge 2 commits into
kilisamemarisaaa wants to merge 2 commits into
Conversation
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
Fixes #228.
Root cause
After the closing boundary, Dicer marks itself finished and resets its internal boundary parser. Once pending parts have ended, the multipart wrapper also ends Dicer. A later Busboy write still called parser.write() on that completed Dicer. The call returned false, so Multipart stored the outer callback while waiting for a drain event that can never occur. As a result, Busboy.end() stayed queued and finish was never emitted.
The write path now ignores bytes only when Dicer's closing-boundary state is set. Other non-writable states, such as a parser destroyed before the closing boundary, are not mistaken for epilogue. The regression test also verifies field -> epilogue write callback -> finish ordering and a single finish event.
Reproduction
On unmodified main (4e8de12), a complete body followed by epilogue in the same chunk emitted field=value and finish. Writing that same epilogue after setImmediate emitted the field but still had finish=false and no error after 200 ms.
Validation