Open bbruppac opened 3 years ago
Hi,
Might be worth a search on something like:
nodejs The value "2147483648" is invalid for option "size"
Some interesting articles around and I am not totally convinced this is an error with Rocket.Chat
Can you give us some information on your server resources please?
CPU, RAM, Disk, file storage etc
Thanks.
hi john...
the same behavior occurred on two systems i tested it on. both vms. my dev vm: ubuntu 20 with 8 cpu and 8gb ram and on a server system: centos 7 with 2 cpus and 43 gb ram... both times i used the official docker images
i believe the issue is related to the fact that file streams seem to be filled into memory buffers. these buffers can only hold 2 gb on node.js....
here you see that the file stream is copied into a buffer, which causes the error: https://github.com/RocketChat/Rocket.Chat/blob/3.15.1/app/api/server/v1/rooms.js#L82
can you try to quickly upload a file > 2GB in a rocket chat? that should confirm or deny my point...
Description:
When uploading files bigger than 2GB, an error occurs.
Steps to reproduce:
Expected behavior:
The file should be uploaded successfully
Actual behavior:
An error occurs:
Server Setup Information:
Client Setup Information
Additional context
I look at the code and it seems that files are not streamed from start to finish. They are fed into buffers (therefore files end up completely in the RAM) for processing things like removing metadata and filtering the file data. I read that Node on 64 bit only supports 2GB buffers, so I think it is caused by that. The error logs seem to support that theory:
Relevant logs:
Sever Log Exception in callback of async function: RangeError [ERR_INVALID_OPT_VALUE] [ERR_INVALID_OPT_VALUE]: The value "2147483648" is invalid for option "size" at Function.allocUnsafe (buffer.js:383:3) at Function.concat (buffer.js:564:25) at FileStream. (app/api/server/v1/rooms.js:82:83)
at FileStream.emit (events.js:326:22)
at FileStream.EventEmitter.emit (domain.js:483:12)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'ERR_INVALID_OPT_VALUE'
Client JS Console: