denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.08k stars 5.4k forks source link

deno install'd script re-downloads jsr typechecking dependencies on every run #25404

Open andykais opened 2 months ago

andykais commented 2 months ago

Version: Deno 1.46.2

repro steps

install the script deno install --global --allow-run=ffprobe,ffmpeg --unstable-ffi --check --allow-read --allow-write --allow-ffi --allow-env=DENO_SQLITE_LOCAL,DENO_SQLITE_PATH,HOME,DENO_DIR,XDG_CACHE_HOME --allow-net --name forager-cli --force jsr:@forager/cli@0.4.2

then run the following forager-cli 2>&1 | tee output.txt

This will show

Download https://jsr.io/@forager/web/runtime/control.js
Download https://jsr.io/@forager/web/0.0.6/types
Download https://jsr.io/@forager/web/0.0.6/@sveltejs/kit
Download https://jsr.io/@forager/web/0.0.6/types.js
Download https://jsr.io/@forager/web/0.0.6/page/types.js

on every run. This output appears to go away when I remove the --check flag from the install command: deno install --global --allow-run=ffprobe,ffmpeg --unstable-ffi --check --allow-read --allow-write --allow-ffi --allow-env=DENO_SQLITE_LOCAL,DENO_SQLITE_PATH,HOME,DENO_DIR,XDG_CACHE_HOME --allow-net --name forager-cli --force jsr:@forager/cli@0.4.2

I believe this is because the script compiles with typing references that are non-existent https://jsr.io/@forager/web/0.0.6/server.js#L40972

    /** @type {import('../runtime/control.js').Redirect | HttpError | SvelteKitError | Error} */

I think this is possibly something I can fix with my build system to strip out these bad typing references (this is an autogenerated file deep inside my library, so typing isnt really important). It does feel like there is a deno bug if it continually tries to download a non existent dependency and fails to warn about that anywhere. Also more generally, I don't like that I have control over when my script reaches out to the internet (--allow-net) but I have no control over when deno reaches out to the internet. There is DENO_NO_UPDATE_CHECK, and deno cache ... but that is different than a kind of DENO_NO_NET env var or some such field that I can turn on when I want to avoid any network traffic from deno

andykais commented 2 months ago

found another one that continually re-downloads and does not have to do with --check:

deno install -A --unstable-ffi -n forager-cli jsr:@forager/cli@0.4.6

$ forager-cli
Download https://jsr.io/@forager/web/0.0.10/server/entries/pages/tailwindcss/resolveConfig.js

This is the import it is redownloading: https://jsr.io/@forager/web/0.0.10/server/entries/pages/_page.svelte.js#L3

and I suppose its redownloading because the import is dynamic here https://jsr.io/@forager/web/0.0.10/server/nodes/2.js#L5. I dont have a lot of control over how sveltekit compiles these files :disappointed:. I'm not sure if this is expected behavior or if deno should be caching dynamic imports after the first run. Figured I would bubble this one up here though