Trying to upload a large file to a node js instance using express and it will fail with large files. With the following errormessage:
What can I do to prevent this error (I don't want to chunk the data yet)
Error: Request aborted
at IncomingMessage.<anonymous> (/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js:107:19)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at abortIncoming (http.js:1892:11)
at Socket.serverSocketCloseListener (http.js:1904:5)
at Socket.EventEmitter.emit (events.js:117:20)
at TCP.close (net.js:466:12)
/server/upload/
buffer.js:194
this.parent = new SlowBuffer(this.length);
^
RangeError: length > kMaxLength
at new Buffer (buffer.js:194:21)
at fs.js:220:16
at Object.oncomplete (fs.js:107:15)
31 Jul 14:01:04 - [nodemon] app crashed - waiting for file changes before starting...
Hope someone can help to solve ;-)
If you analyse the error message
buffer.js:194
this.parent = new SlowBuffer(this.length);
^
RangeError: length > kMaxLength
You can see that kMaxLength is a constant that specify the memory limit of a process.
From https://github.com/joyent/node/wiki/FAQ
Currently, by default v8 has a memory limit of 512mb on 32-bit systems, and 1gb on 64-bit systems. The limit can be raised by setting --max-old-space-size to a maximum of ~1gb (32-bit) and ~1.7gb (64-bit), but it is recommended that you split your single process into several workers if you are hitting memory limits.
So you can execute node with the flag
node --max-old-space-size=2000 app.js
The flag units is in MB see ( https://github.com/joyent/node/blob/master/deps/v8/ChangeLog)