imagemin / imagemin-mozjpeg

Imagemin plugin for mozjpeg
MIT License
252 stars 58 forks source link

unhandledRejection resulting in crash when compressing jpg #51

Open DanielBailey-web opened 4 years ago

DanielBailey-web commented 4 years ago

The .jpg file that it crashes with is attached. Before hitting this error, it had compressed approximately 100-125 images successfully. This could be a problem on my side of things, I am only using a try catch block as my error handling as there is no documentation that I could find that explained how else I should attempt this. item-1gxfo9

This is my server output (pm2 logs) when mozjpeg crashes (using asterisks in place of relative paths and pm2 server names):

0| | You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection: 0| | Error: Command was killed with SIGKILL (Forced termination): 0| | ����JFIF���ExifII �2 �  i�  �����]SONYDSC-HX80^ ^  GIMP 2.10.182020:05:30 17:04:59PrintIM0300    $������"�   '��0�   2���0230���  ��   ���/home///node_modules/mozjpeg/vendor/cjpeg -quality 40 -maxmemory 20000000 0| | at makeError (/home///node_modules/imagemin-mozjpeg/node_modules/execa/lib/error.js:59:11) 0| | at handlePromise (/home///node_modules/imagemin-mozjpeg/node_modules/execa/index.js:114:26) 0| | at runMicrotasks () 0| | at processTicksAndRejections (internal/process/task_queues.js:97:5) 0| | at async /home///node_modules/imagemin-mozjpeg/index.js:109:19 0| | at async /home///node_modules/p-pipe/index.js:12:19 0| | at async handleFile (/home///node_modules/imagemin/index.js:21:9) 0| | at async /home///node_modules/imagemin/index.js:54:13 0| | at async Promise.all (index 0) 0| | at async /home///routes/admin.js:56:29

After this error, it begins logging binary (well the ascii interpretation of it at least)

And finally it fataly crashes the pm2 server to the point where I need to restart it using my ecosystem.config file (pm2 is not able to restart itself)

Other files this happens to appear to all have been edited with GIMP (including this one). This issue does not appear to occur when using a computer with gimp installed on it.

This image successfully compressed to webp using imagemin-webp, so I do believe that the error occurred in this package.

The server that is running (and crashing) is using Ubuntu 18.04 LTS and the most up to date nodejs LTS release. These are my dependencies from my package.json:

"dependencies": { "bcryptjs": "^2.4.3", "body-parser": "^1.19.0", "co": "^4.6.0", "cookie-parser": "^1.4.5", "cropperjs": "^1.5.7", "dotenv": "^8.2.0", "ejs": "^3.1.3", "express": "^4.17.1", "express-validator": "^6.5.0", "imagemin": "^7.0.1", "imagemin-mozjpeg": "^9.0.0", "imagemin-pngquant": "^8.0.0", "imagemin-webp": "^6.0.0", "jsonwebtoken": "^8.5.1", "lazysizes": "^5.2.2", "method-override": "^3.0.0", "multer": "^1.4.2", "mysql2": "^2.1.0", "path": "^0.12.7" }

frossi85 commented 4 years ago

I am experiencing the same using the same libs versions while running on Linux Alpine but not on Mac OSX. Does anyone have an idea of how to make this library work with Alpine Linux? I tried everything that I read on the different issues but nothing helped. I always got some error (different for each solution that I found on previous issues)

SMKH-PRO commented 4 years ago

I am facing some problem on Windows 10. happening with pngs too.

Working perfectly on MacOSX

dudeful commented 3 years ago

I was probably having the same issue yesterday, here is a possible solution