squoosh: squoosh cli windows conversion stuck

Installed on Windows 10 with following cmd: npm i -g @squoosh/cli Ran squoosh-cli --webp auto pic.png, which created pic.webp (but it was larger than original png Then tried squoosh-cli --webp '{"quality":75}' pic.png It starts but is stuck on 1 thread, even after 30 min: 0/1 | ▐▨▨▨▨▨╌╌╌╌╌▌ Encoding (8 threads) pic.png: 15.66KB(node:13288) UnhandledPromiseRejectionWarning: Cannot use ‘in’ operator to search for ‘lossless’ in {quality:75} (Use node --trace-warnings ... to show where the warning was created) (node:13288) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:13288) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejection0/1 / ▐▨▨▨▨▨╌╌╌╌╌▌ Encoding (8 threads)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 18 (3 by maintainers)

Most upvoted comments

Windows here!

Funny, I tried first to reproduce on Powershell and there was no issue.

> ~\Downloads\node-v14.15.4-win-x64\node ~\Downloads\node-v14.15.4-win-x64\node_modules\@squoosh\cli\src\index.js --webp '{"quality":75}' .\heaps.png
⠋ (node:15588) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 13 unpipe listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:15588) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 13 error listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit
(node:15588) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 13 close listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit
(node:15588) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 13 finish listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit
1/1 ✔ Squoosh results:
 .\heaps.png: 111.55KB
  └ heaps.webp → 9.86KB (8.83%)

Then, I opened a regular Command Prompt and found that I could reproduce it.

The problem TypeError: Cannot use 'in' operator to search for 'lossless' in {quality:75}:

  • does not occur in powershell (weird!)
  • also occurs in node version 16.4.0
  • has the full stack trace:
TypeError: Cannot use 'in' operator to search for 'lossless' in {quality:75}
    at Object.toWireType (C:\Users\jcao2\dev\squoosh\libsquoosh\build\index.js:1:96950)
    at Object.encode (eval at new_ (C:\Users\jcao2\dev\squoosh\libsquoosh\build\index.js:1:104602), <anonymous>:10:26)
    at encodeImage (C:\Users\jcao2\dev\squoosh\libsquoosh\build\index.js:37:73)
    at async MessagePort.<anonymous> (C:\Users\jcao2\dev\squoosh\libsquoosh\build\index.js:26:742)

Hmm, so further investigation showed me that using this command:

npx @squoosh/cli --webp "{\"quality\":75}" heaps.png (notice the double quotes and escaping)

makes it work on Windows Command Prompt. The root issue has something to do with CLI arg parsing?

Thanks, @PetrusVermaak.

I can’t reproduce this on MacOS or Linux. So I guess this is an issue with Windows. I don’t have a machine at hand, so if anyone wants to help here, that’d be awesome.

$ docker run --rm -ti -v /Users/surma/Downloads:/Downloads node:14.15.4 /bin/bash

# root@acab10b6660b:/# npm i -g @squoosh/cli
/usr/local/bin/squoosh-cli -> /usr/local/lib/node_modules/@squoosh/cli/src/index.js
/usr/local/bin/cli -> /usr/local/lib/node_modules/@squoosh/cli/src/index.js
+ @squoosh/cli@0.7.1
added 37 packages from 39 contributors in 2.815s

# root@acab10b6660b:/# squoosh-cli --webp '{"quality":75}' /Downloads/squoosh.png 
1/1 ✔ Squoosh results:
 /Downloads/squoosh.png: 72.68KB
  └ squoosh.webp → 13.79KB (19.0%)