javascript - Upload a large file (1GB) with node and express -
trying upload large file node js instance using express , fail large files. following errormessage:
error: request aborted @ incomingmessage.<anonymous> (/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js:107:19) @ incomingmessage.eventemitter.emit (events.js:92:17) @ abortincoming (http.js:1892:11) @ socket.serversocketcloselistener (http.js:1904:5) @ socket.eventemitter.emit (events.js:117:20) @ tcp.close (net.js:466:12) /server/upload/ buffer.js:194 this.parent = new slowbuffer(this.length); ^ rangeerror: length > kmaxlength @ new buffer (buffer.js:194:21) @ fs.js:220:16 @ object.oncomplete (fs.js:107:15) 31 jul 14:01:04 - [nodemon] app crashed - waiting file changes before starting...
what can prevent error when don't want chunk data?
hope can solve ;-)
if analyse error message
buffer.js:194 this.parent = new slowbuffer(this.length); ^ rangeerror: length > kmaxlength
you can see kmaxlength constant specify memory limit of process.
https://github.com/joyent/node/wiki/faq
currently, default v8 has memory limit of 512mb on 32-bit systems, , 1gb on 64-bit systems. limit can raised setting --max-old-space-size maximum of ~1gb (32-bit) , ~1.7gb (64-bit), recommended split single process several workers if hitting memory limits.
so can execute node flag
node --max-old-space-size=2000 app.js
the flag units in mb see ( https://github.com/joyent/node/blob/master/deps/v8/changelog)
Comments
Post a Comment