socketio-file-upload
socketio-file-upload copied to clipboard
Possible memory issue
Hello.
There is possible issue while saving data with write
function that could lead to high memory usage by Node.js process. uploadProgress
function at https://github.com/sffc/socketio-file-upload/blob/master/server.js#L382 doesn't properly handle return value of FileStream write
function.
According to Node documentaion here - https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback
When write
function returns false
, futher attemts to write data should stop until drain
event is emitted. Though data still written, Node buffers all written chunks that could cause issues uploading large files.
Thanks for the report. Ultimately what's happening is that we are attempting to push data into the write stream as it gets sent to us from the socket.io connection. Typically network connections are much slower than file I/O, so my expectation is that the write buffer doesn't usually hit its high water mark. However, it would still be beneficial to properly handle this case.
What made you find this issue? Were you having performance problems and found this via debugging, or are you reporting it as a more theoretical problem?
Hi.
I had some non relevant issues while saving files on my local machine. So i checked out source code and stumbled upon code mentioned above. I played with emitChunkFailed
prop and it does really emitted error
event which meant stream highWaterMark
was hit. Same result for staging server.
I have not done any stress test for now so i cant confidently report this to be an issue.