oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.92k stars 2.75k forks source link

Investigate unnecessarily redownloading packages after install on macOS #1572

Closed nikitavoloboev closed 1 year ago

nikitavoloboev commented 1 year ago

What version of Bun is running?

0.3.0

What platform is your computer?

Darwin 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64 arm

What steps can reproduce the bug?

Clone repo. And run: bun install.

I get it to finish installing after 6 minutes:

 + typescript@4.9.3
 + yup@0.32.11

 1236 packages installed [377.53s]

~/clones/web-public remotes/origin/misc-refactor~38^2~2* 6m 18s
base ❯

If I rm -rf node_modules and run it again. It's still 6+ minutes so no cache gets applied.

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior?

Installs should be very fast especially with cache. https://pnpm.io works correctly.

What do you see instead?

Takes a long time. I am also on bad network though during those tests.

Additional information

No response

nikitavoloboev commented 1 year ago
~/clones/jsonhero-web main
base ❯ bun install
bun install v0.3.0 (074f2369)
 + @cloudflare/workers-types@2.2.2
 + @remix-run/dev@1.8.0
 + @tailwindcss/forms@0.4.1
 + @types/color@3.0.3
 + @types/jest@27.5.2
 + @types/lodash-es@4.17.6
 + @types/react@17.0.52
 + @types/react-dom@17.0.18
 + @types/ua-parser-js@0.7.36
 + concurrently@7.6.0
 + esbuild-visualizer@0.3.1
 + jest@27.5.1
 + miniflare@2.11.0
 + patch-package@6.5.0
 + rimraf@3.0.2
 + tailwindcss@3.2.4
 + ts-jest@27.1.5
 + typescript@4.9.3
 + wrangler@2.5.0
 + @apihero/fetch@0.1.0
 + @codemirror/lang-json@0.19.2
 + @codemirror/rangeset@0.19.9
 + @heroicons/react@1.0.6
 + @js-temporal/polyfill@0.3.0
 + @jsonhero/fuzzy-json-search@0.2.2
 + @jsonhero/json-infer-types@1.2.11
 + @jsonhero/json-schema-fns@0.0.1
 + @jsonhero/path@1.0.21
 + @jsonhero/schema-infer@0.1.4
 + @radix-ui/react-dialog@0.1.7
 + @radix-ui/react-popover@0.1.6
 + @radix-ui/react-tabs@0.1.5
 + @radix-ui/react-toast@1.0.0
 + @remix-run/cloudflare-workers@1.8.0
 + @remix-run/react@1.8.0
 + @remix-run/serve@1.8.0
 + @swan-io/boxed@0.2.1
 + @uiw/react-codemirror@4.15.1
 + @xmldom/xmldom@0.8.6
 + clsx@1.2.1
 + color@4.2.3
 + downshift@6.1.12
 + fathom-client@3.5.0
 + framer-motion@6.5.1
 + json-source-map@0.6.1
 + jwt-decode@3.1.2
 + lodash-es@4.17.21
 + nanoid@3.3.4
 + react@17.0.2
 + react-dom@17.0.2
 + react-dropzone@11.7.1
 + react-hotkeys-hook@3.4.7
 + react-use-intercom@2.0.0
 + react-virtual@2.10.4
 + remix@1.8.0
 + tailwindcss-radix@1.6.0
 + tiny-invariant@1.3.1
 + ts-pattern@3.3.5
Using 'cloudflare-workers' as a platform value is deprecated. Use 'cloudflare' instead.
HINT: check the `postinstall` script in `package.json`
Successfully setup Remix for cloudflare.

 1230 packages installed [37.98s]

~/clones/jsonhero-web main* 39s
base ❯ rm -rf node_modules/

~/clones/jsonhero-web main*
base ❯ bun install
bun install v0.3.0 (074f2369)
 + @cloudflare/workers-types@2.2.2
 + @remix-run/dev@1.8.0
 + @tailwindcss/forms@0.4.1
 + @types/color@3.0.3
 + @types/jest@27.5.2
 + @types/lodash-es@4.17.6
 + @types/react@17.0.52
 + @types/react-dom@17.0.18
 + @types/ua-parser-js@0.7.36
 + concurrently@7.6.0
 + esbuild-visualizer@0.3.1
 + jest@27.5.1
 + miniflare@2.11.0
 + patch-package@6.5.0
 + rimraf@3.0.2
 + tailwindcss@3.2.4
 + ts-jest@27.1.5
 + typescript@4.9.3
 + wrangler@2.5.0
 + @apihero/fetch@0.1.0
 + @codemirror/lang-json@0.19.2
 + @codemirror/rangeset@0.19.9
 + @heroicons/react@1.0.6
 + @js-temporal/polyfill@0.3.0
 + @jsonhero/fuzzy-json-search@0.2.2
 + @jsonhero/json-infer-types@1.2.11
 + @jsonhero/json-schema-fns@0.0.1
 + @jsonhero/path@1.0.21
 + @jsonhero/schema-infer@0.1.4
 + @radix-ui/react-dialog@0.1.7
 + @radix-ui/react-popover@0.1.6
 + @radix-ui/react-tabs@0.1.5
 + @radix-ui/react-toast@1.0.0
 + @remix-run/cloudflare-workers@1.8.0
 + @remix-run/react@1.8.0
 + @remix-run/serve@1.8.0
 + @swan-io/boxed@0.2.1
 + @uiw/react-codemirror@4.15.1
 + @xmldom/xmldom@0.8.6
 + clsx@1.2.1
 + color@4.2.3
 + downshift@6.1.12
 + fathom-client@3.5.0
 + framer-motion@6.5.1
 + json-source-map@0.6.1
 + jwt-decode@3.1.2
 + lodash-es@4.17.21
 + nanoid@3.3.4
 + react@17.0.2
 + react-dom@17.0.2
 + react-dropzone@11.7.1
 + react-hotkeys-hook@3.4.7
 + react-use-intercom@2.0.0
 + react-virtual@2.10.4
 + remix@1.8.0
 + tailwindcss-radix@1.6.0
 + tiny-invariant@1.3.1
 + ts-pattern@3.3.5
Using 'cloudflare-workers' as a platform value is deprecated. Use 'cloudflare' instead.
HINT: check the `postinstall` script in `package.json`
Successfully setup Remix for cloudflare.

 1230 packages installed [40.02s]

~/clones/jsonhero-web main* 41s
base ❯

Check this @Jarred-Sumner

Caching fully broken for me.

Is repo, first time doing clone on it https://github.com/apihero-run/jsonhero-web

colinhacks commented 1 year ago

This is working for me on Bun v0.3 on an M1 Mac. @nikitavoloboev are you still experiencing this?

nikitavoloboev commented 1 year ago

@colinhacks

ok just tried it again on https://github.com/Xiphe/cachified (first time cloning repo). I upgraded to latest bun with bun upgrade --canary before doing this test and on 13.0.1 M1 macOS

bun install
bun install v0.3.0 (42ea8b24)
  🔍 bs-logger [17/39]
error: package "redis4" not found registry.npmjs.org/redis4 404
 + @types/jest@29.2.3
 + @types/node@18.11.10
 + @types/redis-mock@0.17.1
 + esbuild@0.15.16
 + jest@29.3.1
 + lru-cache@7.14.1
 + redis-mock@0.56.3
 + ts-jest@29.0.3
 + typescript@4.9.3
$ bun run build:declarations && bun run build:esm && bun run build:cjs
$ tsc && rm dist/cachified.spec.d.ts
$ esbuild src/index.ts --outfile=dist/index.js --format=esm --bundle --target=es2020 --sourcemap --minify

  dist/index.js       7.3kb
  dist/index.js.map  40.9kb

⚡ Done in 7ms
$ esbuild src/index.ts --outfile=dist/index.cjs --format=cjs --bundle --target=es2016 --sourcemap

  dist/index.cjs      20.3kb
  dist/index.cjs.map  41.4kb

⚡ Done in 4ms

 289 packages installed [28.28s]

rm -rf node_modules/
bun install
bun install v0.3.0 (42ea8b24)
 + @types/jest@29.2.3
 + @types/node@18.11.10
 + @types/redis-mock@0.17.1
 + esbuild@0.15.16
 + jest@29.3.1
 + lru-cache@7.14.1
 + redis-mock@0.56.3
 + ts-jest@29.0.3
 + typescript@4.9.3
$ bun run build:declarations && bun run build:esm && bun run build:cjs
$ tsc && rm dist/cachified.spec.d.ts
$ esbuild src/index.ts --outfile=dist/index.js --format=esm --bundle --target=es2020 --sourcemap --minify

  dist/index.js       7.3kb
  dist/index.js.map  40.9kb

⚡ Done in 6ms
$ esbuild src/index.ts --outfile=dist/index.cjs --format=cjs --bundle --target=es2016 --sourcemap

  dist/index.cjs      20.3kb
  dist/index.cjs.map  41.4kb

⚡ Done in 3ms

 289 packages installed [10.95s]

rm -rf node_modules/
bun install
bun install v0.3.0 (42ea8b24)
 + @types/jest@29.2.3
 + @types/node@18.11.10
 + @types/redis-mock@0.17.1
 + esbuild@0.15.16
 + jest@29.3.1
 + lru-cache@7.14.1
 + redis-mock@0.56.3
 + ts-jest@29.0.3
 + typescript@4.9.3
$ bun run build:declarations && bun run build:esm && bun run build:cjs
$ tsc && rm dist/cachified.spec.d.ts
$ esbuild src/index.ts --outfile=dist/index.js --format=esm --bundle --target=es2020 --sourcemap --minify

  dist/index.js       7.3kb
  dist/index.js.map  40.9kb

⚡ Done in 7ms
$ esbuild src/index.ts --outfile=dist/index.cjs --format=cjs --bundle --target=es2016 --sourcemap

  dist/index.cjs      20.3kb
  dist/index.cjs.map  41.4kb

⚡ Done in 3ms

 289 packages installed [17.09s]

in short, first time is 28s, then 11s, then 17s. I rm -rf node_modules inbetween runs. So I'd think it doesn't work as I'd expect faster installs, like it all should be cached in my view, 17s is still too long time, maybe I am mistaken though.

@Jarred-Sumner can maybe say if those times are a bug or not.

Electroid commented 1 year ago

This issue was fixed many releases ago. If you can still reproduce this with Bun v1.0.x, please feel free to re-open this issue.