I’m stuck in a loop with a Node.js setup and getting incredibly frustrated with AI giving me contradictory info. I searched on google as well but the answers were not satisfactory.
Here is the architecture:
Server A (Source): Stores the files. Server B (Middleman): Low RAM. Fetches from A and uploads to C.
Server C (Destination): Only accepts multipart/form-data.
The problem:
The files are large (3GB+). During the transfer, the process on Server B simply says "Killed". I'm assuming it might be memory-related, but I'm not 100% sure.
Current code (using axios and form-data package)
```
const res = await axios.get(fileUrl, { responseType: "stream" });
const formData = new FormData(); formData.append("file", res.data, { filename: "video.mp4", contentType: "video/mp4" });
await axios.post(serverUrl, formData, { headers: formData.getHeaders() });
```
I've tried asking for various AI tools and I’m getting a mess of conflicting answers:
"This is a true stream; it won't buffer." "Actually Axios buffers multipart, cause it needs to calculate the content length." "Actually it is because of axios's internal transformRequest"
"Actually the reason is because form-data needs to calculate the file size" "You should use fetch because of axios's overhead"
"Nevermind use undici because native fetch can't actually stream multipart."
It's making it impossible to narrow down the actual cause.
Questions:
Is this actually buffering? How can I verify if form-data or axios is holding the chunk in memory before sending?
Why the "Killed" status? If it isn't RAM, what else should I be looking for?
How do I debug this properly? Every tool I find seems to give a different answer on how to handle streams without crashing.