How to handle Array buffer allocation failed in nodejs?

I have successfully uploaded the image in nodejs and for this I am using multer. But once, “Array allocation error failed” and I want to handle this error. I tried to save the code in a try-catch block, although it still throws an error, and I cannot figure out how to deal with this error or how to avoid this error? Ability to upload a file, but when I try to change the height and width and create a new image, it gives an error message

Uncaught RangeError: unsuccessful array buffer allocation

in Buffer.Uint8Array (native)

in FastBuffer (buffer.js: 8: 1)

OR

Failed to assign array buffer

in Buffer.Uint8Array (native)

in FastBuffer (buffer.js: 8: 1)

RangeError: array buffer mismatch in the new Uint8Array (native) in Object.getData (/ Burg_nodejs / node_modules / jpeg-js / lib / decoder.js: 797: 18) in Object.copyToImageData (/ Burg_nodejs / node_modules / jpeg-js / lib /decoder.js:913:23) in Object.decode (/Burg_nodejs/node_modules/jpeg-js/lib/decoder.js:985:11) in Jimp.parseBitmap (/Burg_nodejs/node_modules/jimp/index.jshaps10 : 36) to / Burg _nodejs / node_modules / jimp / index.js: 202: 29 to FSReqWrap.readFileAfterClose [as incomplete] (fs.js: 446: 3)

Any suggestion would be much more helpful.

+4
source share

Source: https://habr.com/ru/post/1684612/


All Articles