[LibSquoosh] URL invalid
SettingDust opened this issue ยท 14 comments
Describe the bug
Use the github action to compress images. It's says can'tt find the wasm files. But there is in repo.
git clone 'https://github.com/SettingDust/image-compress-action' # ref=main
docker cp src=/home/runner/.cache/act/SettingDust-image-compress-action@main dst=/actions/
TypeError [ERR_INVALID_URL]: Invalid URL: /actions/SettingDust-image-compress-action@main/dist/mozjpeg_node_enc-13aa762d.wasm
at onParseError (internal/url.js:259:9)
at new URL (internal/url.js:335:5)
at Object.7275 (/actions/SettingDust-image-compress-action@main/webpack:/image-compress-action/node_modules/@squoosh/lib/build/index.js:1:1)
at __nccwpck_require__ (/actions/SettingDust-image-compress-action@main/webpack:/image-compress-action/webpack/bootstrap:21:1)
at Object.3109 (/actions/SettingDust-image-compress-action@main/webpack:/image-compress-action/lib/main.js:37:1)
at __nccwpck_require__ (/actions/SettingDust-image-compress-action@main/webpack:/image-compress-action/webpack/bootstrap:21:1)
at /actions/SettingDust-image-compress-action@main/webpack:/image-compress-action/webpack/startup:4:1
at Object.<anonymous> (/actions/SettingDust-image-compress-action@main/dist/index.js:12521:12)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
Error: exit with `FAILURE`: 1
Expected behavior
Compress
Version:
- OS w/ version: ubuntu-18.04 in docker. Host is ubuntu-20.04 in docker.
- Node version: May be 14.17.0. There isn't detail in action log.
- npm version: May be 6.14.13.
Can you add how you are invoking the CLI? Your error log is not showing that.
Can you add how you are invoking the CLI? Your error log is not showing that.
It's not cli. It's called by js.
https://github.com/SettingDust/image-compress-action/blob/main/src/main.ts#L25
Can you give me a reproduction case then? The error gives me very little to go on, sadly.
Can you give me a reproduction case then? The error gives me very little to go on, sadly.
Gotcha. It's caused by ncc
https://github.com/SettingDust/squoosh-test
After I add the ncc to compile the project, the error appearing.
TypeError [ERR_INVALID_URL]: Invalid URL: /home/runner/work/squoosh-test/squoosh-test/dist/mozjpeg_node_enc-13aa762d.wasm
at onParseError (internal/url.js:259:9)
at new URL (internal/url.js:335:5)
at Object.275 (/home/runner/work/squoosh-test/squoosh-test/webpack:/squoosh-test/node_modules/@squoosh/lib/build/index.js:1:1)
at __nccwpck_require__ (/home/runner/work/squoosh-test/squoosh-test/webpack:/squoosh-test/webpack/bootstrap:21:1)
at /home/runner/work/squoosh-test/squoosh-test/webpack:/squoosh-test/index.js:1:1
at /home/runner/work/squoosh-test/squoosh-test/dist/index.js:4178:3
at Object.<anonymous> (/home/runner/work/squoosh-test/squoosh-test/dist/index.js:4181:12)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
I just published @squoosh/lib
v0.3.0 which fixes a lot of things. Can you try again with this new version?
Same with 0.3.1
TypeError [ERR_INVALID_URL]: Invalid URL: /home/runner/work/squoosh-test/squoosh-test/dist/mozjpeg_node_enc-ec78f622.wasm
at onParseError (internal/url.js:259:9)
at new URL (internal/url.js:335:5)
at Object.275 (/home/runner/work/squoosh-test/squoosh-test/webpack:/squoosh-test/node_modules/@squoosh/lib/build/index.js:1:1)
at __nccwpck_require__ (/home/runner/work/squoosh-test/squoosh-test/webpack:/squoosh-test/webpack/bootstrap:21:1)
at /home/runner/work/squoosh-test/squoosh-test/webpack:/squoosh-test/index.js:1:1
at /home/runner/work/squoosh-test/squoosh-test/dist/index.js:4178:3
at Object.<anonymous> (/home/runner/work/squoosh-test/squoosh-test/dist/index.js:4181:12)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
Same here using @squoosh/lib@0.4.0
:
1:13:37 PM: throw new TypeError("Failed to parse URL from " + input, { cause: err });
1:13:37 PM: ^
1:13:37 PM: TypeError: Failed to parse URL from /opt/build/repo/node_modules/@squoosh/lib/build/imagequant_node-a4aafbae.wasm
1:13:37 PM: at new Request (node:internal/deps/undici/undici:4813:19)
1:13:37 PM: at Agent.fetch2 (node:internal/deps/undici/undici:5539:29)
1:13:37 PM: ... 4 lines matching cause stack trace ...
1:13:37 PM: at /opt/build/repo/node_modules/@squoosh/lib/build/index.js:28:35216
1:13:37 PM: at instantiateEmscriptenWasm (/opt/build/repo/node_modules/@squoosh/lib/build/index.js:1:466)
1:13:37 PM: at Object.<anonymous> (/opt/build/repo/node_modules/@squoosh/lib/build/index.js:30:323)
1:13:37 PM: at Module._compile (node:internal/modules/cjs/loader:1105:14) {
1:13:37 PM: [cause]: TypeError [ERR_INVALID_URL]: Invalid URL
1:13:37 PM: at new NodeError (node:internal/errors:377:5)
1:13:37 PM: at URL.onParseError (node:internal/url:563:9)
1:13:37 PM: at new URL (node:internal/url:643:5)
1:13:37 PM: at new Request (node:internal/deps/undici/undici:4811:25)
1:13:37 PM: at Agent.fetch2 (node:internal/deps/undici/undici:5539:29)
1:13:37 PM: at Object.fetch (node:internal/deps/undici/undici:6370:20)
1:13:37 PM: at fetch (node:internal/bootstrap/pre_execution:196:25)
1:13:37 PM: at instantiateAsync (/opt/build/repo/node_modules/@squoosh/lib/build/index.js:28:11469)
1:13:37 PM: at createWasm
Same as above, file node_modules/@squoosh/lib/build/imagequant_node-a4aafbae.wasm
exists..
Any hints or pointers would be very appreciated.
Suddenly seeing this upon building a project that was last worked on 2 weeks ago. The only thing that has changed for me was node 18 being upgraded to a newer version, so perhaps that's the root cause.
The only thing that has changed for me was node 18 being upgraded to a newer version, so perhaps that's the root cause.
Forr anyone running into the same problem: Temporarily downgrading to node >=v16 when using @squoosh/lib@0.4.0
is a successful workaround. Thank you ๐ช
Seeing this too with node 18
jchatt@MM4JJQ02Y7 Pictures % squoosh-cli --help
Usage: squoosh-cli [options] <files...>
Options:
-d, --output-dir <dir> Output directory (default: ".")
-s, --suffix <suffix> Append suffix to output files (default: "")
--max-optimizer-rounds <rounds> Maximum number of compressions to use for auto optimizations
(default: "6")
--optimizer-butteraugli-target <butteraugli distance> Target Butteraugli distance for auto optimizer (default: "1.4")
--resize [config] Resize the image before compressing
--quant [config] Reduce the number of colors used (aka. paletting)
--rotate [config] Rotate image
--mozjpeg [config] Use MozJPEG to generate a .jpg file with the given configuration
--webp [config] Use WebP to generate a .webp file with the given configuration
--avif [config] Use AVIF to generate a .avif file with the given configuration
--jxl [config] Use JPEG-XL to generate a .jxl file with the given configuration
--wp2 [config] Use WebP2 to generate a .wp2 file with the given configuration
--oxipng [config] Use OxiPNG to generate a .png file with the given configuration
-h, --help display help for command
jchatt@MM4JJQ02Y7 Pictures % squoosh-cli --mozjpeg auto day2.jpg
(node:34945) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/deps/undici/undici:4832
throw new TypeError("Failed to parse URL from " + input, { cause: err });
^
TypeError: Failed to parse URL from /opt/homebrew/lib/node_modules/@squoosh/cli/node_modules/@squoosh/lib/build/imagequant_node-a4aafbae.wasm
at new Request (node:internal/deps/undici/undici:4832:19)
at Agent.fetch2 (node:internal/deps/undici/undici:5524:29)
... 4 lines matching cause stack trace ...
at /opt/homebrew/lib/node_modules/@squoosh/cli/node_modules/@squoosh/lib/build/index.js:28:35216
at instantiateEmscriptenWasm (/opt/homebrew/lib/node_modules/@squoosh/cli/node_modules/@squoosh/lib/build/index.js:1:466)
at Object.<anonymous> (/opt/homebrew/lib/node_modules/@squoosh/cli/node_modules/@squoosh/lib/build/index.js:30:323)
at Module._compile (node:internal/modules/cjs/loader:1112:14) {
[cause]: TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:388:5)
at URL.onParseError (node:internal/url:564:9)
at new URL (node:internal/url:644:5)
at new Request (node:internal/deps/undici/undici:4830:25)
at Agent.fetch2 (node:internal/deps/undici/undici:5524:29)
at Object.fetch (node:internal/deps/undici/undici:6351:20)
at fetch (node:internal/bootstrap/pre_execution:197:25)
at instantiateAsync (/opt/homebrew/lib/node_modules/@squoosh/cli/node_modules/@squoosh/lib/build/index.js:28:11469)
at createWasm (/opt/homebrew/lib/node_modules/@squoosh/cli/node_modules/@squoosh/lib/build/index.js:28:12079)
at /opt/homebrew/lib/node_modules/@squoosh/cli/node_modules/@squoosh/lib/build/index.js:28:35216 {
input: '/opt/homebrew/lib/node_modules/@squoosh/cli/node_modules/@squoosh/lib/build/imagequant_node-a4aafbae.wasm',
code: 'ERR_INVALID_URL'
}
}
Node.js v18.5.0
Status: Same problem ๐
1. Environment
- Microsoft Windows [Version 10.0.19041.1415]
- Node.js v18.7.0
- @squoosh/cli@0.7.2
- @squoosh/lib@0.4.0
2. Console output
D:\SashaDebugging\KiraSquooshImages>npm i -g @squoosh/cli
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@squoosh/cli@0.7.2',
npm WARN EBADENGINE required: { node: ' ^12.20.2 || ^14.13.1 || ^16.0.0 ' },
npm WARN EBADENGINE current: { node: 'v18.7.0', npm: '8.16.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@squoosh/lib@0.4.0',
npm WARN EBADENGINE required: { node: ' ^12.5.0 || ^14.0.0 || ^16.0.0 ' },
npm WARN EBADENGINE current: { node: 'v18.7.0', npm: '8.16.0' }
npm WARN EBADENGINE }
added 37 packages, and audited 38 packages in 9s
11 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
D:\SashaDebugging\KiraSquooshImages>squoosh-cli --help
Usage: squoosh-cli [options] <files...>
Options:
-d, --output-dir <dir> Output directory (default: ".")
-s, --suffix <suffix> Append suffix to output files (default: "")
--max-optimizer-rounds <rounds> Maximum number of compressions to use for auto optimizations (default: "6")
--optimizer-butteraugli-target <butteraugli distance> Target Butteraugli distance for auto optimizer (default: "1.4")
--resize [config] Resize the image before compressing
--quant [config] Reduce the number of colors used (aka. paletting)
--rotate [config] Rotate image
--mozjpeg [config] Use MozJPEG to generate a .jpg file with the given configuration
--webp [config] Use WebP to generate a .webp file with the given configuration
--avif [config] Use AVIF to generate a .avif file with the given configuration
--jxl [config] Use JPEG-XL to generate a .jxl file with the given configuration
--wp2 [config] Use WebP2 to generate a .wp2 file with the given configuration
--oxipng [config] Use OxiPNG to generate a .png file with the given configuration
-h, --help display help for command
D:\SashaDebugging\KiraSquooshImages>squoosh-cli "KiraTestImage.jpg"
node:internal/deps/undici/undici:6277
p.reject(Object.assign(new TypeError("fetch failed"), { cause: response.error }));
^
TypeError: fetch failed
at Object.processResponse (node:internal/deps/undici/undici:6277:34)
at node:internal/deps/undici/undici:6602:42
at node:internal/process/task_queues:140:7
at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) {
cause: Error: unknown scheme
at makeNetworkError (node:internal/deps/undici/undici:5251:51)
at schemeFetch (node:internal/deps/undici/undici:6578:18)
at node:internal/deps/undici/undici:6434:26
at mainFetch (node:internal/deps/undici/undici:6451:11)
at fetching (node:internal/deps/undici/undici:6408:7)
at Agent.fetch2 (node:internal/deps/undici/undici:6288:20)
at Object.fetch (node:internal/deps/undici/undici:7076:20)
at fetch (node:internal/bootstrap/pre_execution:199:25)
at instantiateAsync (C:\Program Files\nodejs\node_modules\@squoosh\cli\node_modules\@squoosh\lib\build\index.js:28:11469)
at createWasm (C:\Program Files\nodejs\node_modules\@squoosh\cli\node_modules\@squoosh\lib\build\index.js:28:12079) {
[cause]: undefined
}
}
Node.js v18.7.0
I get the same result for different images in different formats.
Thanks.
Unfortunately, due to a few people leaving the team, and staffing issues resulting from the current economic climate (ugh), the CLI and libsquoosh packages are no longer actively maintained. I know that sucks, but there simply isn't the time & people to work on this. If anyone from the community wants to fork it, you have my blessing. The squoosh.app web app will continue to be supported and improved.
same error TypeError: fetch failed cause: Error: unknown scheme
when using @squoosh/lib v0.4.0 and nodejs v18.10.0
fixed by running nodejs with the flag --no-experimental-fetch
To make it work with the CLI, you can pass the flag using environment variables.
export NODE_OPTIONS='--no-experimental-fetch'
squoosh-cli \
--resize '{"enabled":true,"width":560,"height":560,"method":"lanczos3","fitMethod":"stretch","premultiply":true,"linearRGB":true}' \
--webp '{"quality":90,"target_size":0,"target_PSNR":0,"method":6,"sns_strength":50,"filter_strength":60,"filter_sharpness":0,"filter_type":1,"partitions":0,"segments":4,"pass":1,"show_compressed":0,"preprocessing":0,"autofilter":0,"partition_limit":0,"alpha_compression":1,"alpha_filtering":1,"alpha_quality":100,"lossless":0,"exact":0,"image_hint":0,"emulate_jpeg_size":0,"thread_level":0,"low_memory":0,"near_lossless":100,"use_delta_palette":0,"use_sharp_yuv":0}' \
-d compressed/ \
source/1105.jpg