Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning: Error: stdout read ENOTCONN #367

Open
yudiznilay opened this issue Aug 21, 2020 · 3 comments
Open

UnhandledPromiseRejectionWarning: Error: stdout read ENOTCONN #367

yudiznilay opened this issue Aug 21, 2020 · 3 comments

Comments

@yudiznilay
Copy link

Great plugin by the way.
Facing this following issue while converting images to webp
(node:4267) UnhandledPromiseRejectionWarning: Error: stdout read ENOTCONN at tryReadStart (net.js:558:20) at Socket._read (net.js:569:5) at Socket.Readable.read (_stream_readable.js:491:10) at Socket.read (net.js:609:39) at new Socket (net.js:363:12) at Object.Socket (net.js:254:41) at createSocket (internal/child_process.js:311:14) at ChildProcess.spawn (internal/child_process.js:424:23) at Object.spawn (child_process.js:540:9) at module.exports (/path/node_modules/execa/index.js:139:26) (node:4267) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2085) (node:4267) [DEP0018] 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.

npm version: 6.14.7
packages installed: imagemin and imagemin-webp
Code
`const imagemin = require('imagemin');
const imageminWebp = require('imagemin-webp');
var folder = 'path';

imagemin([folder], {
destination: folder,
plugins: [imageminWebp({ quality: 80 })]
}).then(() => {
console.log('Done!');
});`

@bkarlson
Copy link

Same issue with mozjpeg plugin:

(node:20240) UnhandledPromiseRejectionWarning: Error: Command failed with ENOTCONN: /scripts/node_modules/mozjpeg/vendor/cjpeg
read ENOTCONN


    at tryReadStart (net.js:574:20)
    at Socket._read (net.js:585:5)
    at Socket.Readable.read (_stream_readable.js:475:10)
    at Socket.read (net.js:625:39)
    at new Socket (net.js:377:12)
    at Object.Socket (net.js:269:41)
    at createSocket (internal/child_process.js:313:14)
    at ChildProcess.spawn (internal/child_process.js:436:23)
    at Object.spawn (child_process.js:553:9)
    at execa (scripts/node_modules/imagemin-mozjpeg/node_modules/execa/index.js:80:26)

@bkarlson
Copy link

Possible cause: too many files in a folder (~2500) and imagemin failing to tackle all of them in async manner. If imagemin is set to iterate files one by one, everything is processed without errors.

@kirwako
Copy link

kirwako commented Jul 24, 2022

I fix this bug in imagemin package with this Pull Request
I hope imagemin merges it with their source code
otherwise you can use imageminimize package it's like imagemin but large numbers of files are working on it and more optimized than imagemin
PS: imageminimize get the same options as imagemin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants