Replace form-data with Node streams - #1324
Merged
Benjamin Christopher Simmonds (benibenj) merged 4 commits intoSep 4, 2026
Merged
Benjamin Christopher Simmonds (benibenj) merged 4 commits into
Benjamin Christopher Simmonds (benibenj) merged 4 commits into
Conversation
Jake Bailey (jakebailey)
force-pushed
the
remove-form-data
branch
from
September 3, 2026 21:19
ecddae2 to
a3cffe2
Compare
| yield lineBreak; | ||
| } | ||
|
|
||
| yield `--${boundary}--${lineBreak}`; |
Member
Author
There was a problem hiding this comment.
It still boggles my mind that this is how multipart form-data works
Keep the request lifecycle and released file handles the same as they were with form-data: - Do not remove the error listener in runWithStreamError once the operation settles. A stream error arriving afterwards was an unhandled 'error' event, which terminates the process. - Create the stream with autoDestroy: false. Readable.from emits 'close' after 'end', and typed-rest-client ends the request on both, so every successful upload called req.end() twice. CombinedStream never emitted 'close'. - Destroy the parts once the stream is done with them. Both file streams open eagerly, so a request that failed before consuming the form kept the package locked, which made the temporary directory cleanup in withTemporaryPackage fail and hid the original error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Benjamin Christopher Simmonds (benibenj)
enabled auto-merge
September 4, 2026 13:49
Benjamin Christopher Simmonds (benibenj)
approved these changes
Sep 4, 2026
Giuseppe Cianci (Giuspepe)
approved these changes
Sep 4, 2026
Benjamin Christopher Simmonds (benibenj)
merged commit Sep 4, 2026
ae9f2b7
into
microsoft:main
5 checks passed
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.
This can be replaced with a bit of code in the repo, deleting 8 prod deps.
I though it would be more but no, headers were already being manually constructed, so it's all just boilerplate with Node's streaming. There's more "handle errors in streams" code than actual form code, and then way more testing than actual form and error code.