Reputation: 2701
When we work with streams in node js, it's easy to understand data flow from disk to node js then to disk. But what if the stream is from request body? The data flow through network when they are read or node.js saves the whole stream in it's memory?
Upvotes: 0
Views: 62
Reputation: 707158
The request body is an incoming stream over the network. node.js will read part of it from TCP, fill up a local buffer and then not read any more until some of it is read locally out of the buffer to make more room in the buffer.
The data flow through network when they are read
Yes, with some local buffering in the stream object and also in the TCP stack for efficiency. TCP will use flow control to tell the source to pause sending if the local buffers are full.
or node.js saves the whole stream in it's memory?
No, not all in memory.
Upvotes: 1