I have successfully upload image in nodejs and I am using multer for that. But sometime " Array buffer allocation failed " error occurs and I want to handle that error. I tried to keep the code in try-catch block even though still it throws the error and I am unable to figure out how to handle this error or how to avoid that error ? Able to upload file but when I try to change height and width and making a new image then it throws an error
Uncaught RangeError: Array buffer allocation failed
at Buffer.Uint8Array (native)
at FastBuffer (buffer.js:8:1)
OR
Array buffer allocation failed
at Buffer.Uint8Array (native)
at FastBuffer (buffer.js:8:1)
RangeError: Array buffer allocation failed
at new Uint8Array (native)
at Object.getData (/Burg_nodejs/node_modules/jpeg-js/lib/decoder.js:797:18)
at Object.copyToImageData (/Burg_nodejs/node_modules/jpeg-js/lib/decoder.js:913:23)
at Object.decode (/Burg_nodejs/node_modules/jpeg-js/lib/decoder.js:985:11)
at Jimp.parseBitmap (/Burg_nodejs/node_modules/jimp/index.js:310:36)
at /Burg_nodejs/node_modules/jimp/index.js:202:29
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:446:3)
Any suggestion will be much more helpful
Looks like you do not have enough memory to perform a large size upload
Someone in our team had this issue, so we guessed something was off with his machine. Turns out he had node x86 installed. After installing node x64 and rebuilding all the node_modules, the error was gone.
jpeg-js uses inadequate amount of memory for image processing,
- possible solution could be to resize picture (imagemagick/whatever)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With