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.
What and why?
This is another attempt to fix #1129
The file upload retry mechanism is incorrect as it tries to upload the same stream instances multiple times. When a
FormData
(from theform-data
package) is built with a used stream, the resulting stream never ends, so the request never ends, resulting in a "socket hang up" error.Minimal example with
form-data
onlyExample with an actual request
How?
This PR solves the issue by making sure the
MultipartPayload
does not contain streams but only file paths, and theupload
function is then responsible to create streams every time the request is retried.Note
While this particular behavior happens when
form-data
is involved, this is not aform-data
bug, but really an issue related to our own usage of streams. Withoutform-data
:https.request
sends an empty requestfetch
nodejs function throws immediatelyReview checklist