Prevent Axios from fully buffering files uploaded from MSP dashboard #24927
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.
for #24829
See axios/axios#1045 -- by default Axios buffers uploaded files into memory fully, to support redirects. For large file uploads this means we get OOM errors, especially when sending to multiple teams. There's a few other optimizations we can put in place here but in the short term we can fix the buffering issue by setting
maxRedirects: 0
on the requests.I tested this by adding an
onUploadProgress
handler to the Axios request that dumps memory usage, and uploading a 209mb software file to 3 teams. Before the update, the readout ticket up continuously (the first number is the # of bytes uploaded):so we start at ~161mb, and by the time we're done, we're using 637mb of RAM. Render's free tier has a 250mb limit on apps.
With
maxRedirects: 0
, we see:showing that we start and finish with around the same amount of RAM used.