gruntjs / grunt-contrib-imagemin

Minify PNG, JPG, GIF and SVG images.
https://gruntjs.com
MIT License
1.21k stars 175 forks source link

UnhandledPromiseRejectionWarning - imagemin hangs #372

Closed mystikodesign closed 7 years ago

mystikodesign commented 8 years ago

Using grunt-contrib-imagemin, was working perfectly until Node 7.0 update.

Now returns an error in terminal, and hangs: (node:24085) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Expected a buffer (node:24085) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:24085) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Expected a buffer (node:24085) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: Expected a buffer (node:24085) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): TypeError: Expected a buffer

UnDrewHa commented 8 years ago

node 6.7.0, npm 3.10.3. Same error: `(node:15902) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 9): TypeError: Expected a buffer (node:15902) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 10): TypeError: Expected a buffer

Fatal error: stream.on is not a function`

tujlaky commented 8 years ago

Same here (node 6.6.0, npm 3.10.3):

(node:7589) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Expected a buffer (node:7589) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Expected a buffer (node:7589) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: Expected a buffer (node:7589) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): TypeError: Expected a buffer (node:7589) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): TypeError: Expected a buffer (node:7589) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): TypeError: Expected a buffer

tujlaky commented 8 years ago

If I remove mozjpeg everything is working as expected.

MachinisteWeb commented 8 years ago

Same issue for me with « imagemin-jpegtran » and with « imagemin » npm package, others (gif, svg and png) work well.

OS Windows 10 ; node 7.1.0 ; npm 3.10.9.

(node:8088) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error in file: C:/nodejs//template/website/assets/media/images/base.jpg

Command failed: C:\Users\\AppData\Roaming\npm\node_modules\\node_modules\jpegtran-bin\vendor\jpegtran.exe -copy none -optimize -outfile C:\Users\\AppData\Local\Temp\38084f76-af09-46b0-96dc-556355beaa23 C:\Users\\AppData\Local\Temp\ab5075e0-2172-4cf4-b809-df80f480a8ce

(node:8088) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:8088) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Error in file: C:/nodejs//template/website/assets/media/images/main-background.jpg

Command failed: C:\Users\\AppData\Roaming\npm\node_modules\\node_modules\jpegtran-bin\vendor\jpegtran.exe -copy none -optimize -outfile C:\Users\\AppData\Local\Temp\7e993a98-edc5-4600-be5c-027bf9db8e1a C:\Users\\AppData\Local\Temp\161f8f85-d5dd-49ad-8941-0ecbf91b0d4b

nstCactus commented 7 years ago

Any progress on this? Is this something related to configuration or a bug? If so is this a grunt-contrib-imagemin bug or one of its dependencies?

liuyuan512 commented 7 years ago

I have the same problem! Anybody can fix it???

liuyuan (master ) frontend-nanodegree-mobile-portfolio $ grunt imagemin Running "imagemin:static" (imagemin) task (node:15467) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Expected a buffer (node:15467) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Expected a buffer (node:15467) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: Expected a buffer (node:15467) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): TypeError: Expected a buffer (node:15467) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): TypeError: Expected a buffer (node:15467) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): TypeError: Expected a buffer (node:15467) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 7): TypeError: Expected a buffer (node:15467) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): TypeError: Expected a buffer Fatal error: stream.on is not a function liuyuan (master ) frontend-nanodegree-mobile-p

klihelp commented 7 years ago

try to run node with --trace-warnings

LeDavid commented 7 years ago

I'm having the same problem as soon as I have tried to use another plugin for JPG file. I have tried mozjpeg and jpegoptim. Both produce the same error.

humantorch commented 7 years ago

Count me in among those affected. Same error. Rolling back node versions hasn't affected anything (as the original poster noted this happened with the Node 7 update for them).

chillyistkult commented 7 years ago

Same error for me, tried with imageminJpegRecompress().

humantorch commented 7 years ago

Switching to optipng instead of using pngquant solved the issue for me. I have no idea of optipng is any better or worse than pngquant but at least the process runs. ¯\(ツ)

manuelbieh commented 7 years ago

Same problem here. Win 10 1703, Node 6.9.5.

chillyistkult commented 7 years ago

Downgrading to "imagemin-mozjpeg": "^5.1.0" solves the issue (in case you use mozjpeg).

LeDavid commented 7 years ago

It works for me with an older version of plugin: imagemin-jpeg-recompress@4.3.0.

fspin commented 7 years ago

@tujlaky disabling mozjpeg did it to me, and then (on Mac OS Sierra) I installed it brew install mozjpeg and everything went ok. I hope this help somebody.

codeengie commented 7 years ago

I had to downgrade imagemin-{jpeg-recompress,pngquant} to 4.3.0/4.2.2 to get over this issue. Would it be possible to get this fixed/updated so it works with Grunt? Thanks.

kevva commented 7 years ago

Can you try out 2.0.0? If the issue still persists I'll reopen.

yuceltoluyag commented 5 years ago

λ node -v v10.16.0 npm -v 6.9.0 gulp -v [20:49:22] CLI version 3.9.1 [20:49:22] Local version 3.9.1 windows 10 1903 latest lts version same error (node:12860) UnhandledPromiseRejectionWarning: TypeError: Patterns must be a string or an array of strings