sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.73k stars 1.95k forks source link

Build Fails During (Due To?) Log Cleanup Added in @sveltejs/adapter-vercel@1.0.0-next.63 #5577

Closed cryptodeal closed 2 years ago

cryptodeal commented 2 years ago

Describe the bug

Using @sveltejs/adapter-vercel@1.0.0-next.63, I can build a pnpm monorepo (using turborepo) locally, but deployment to Vercel fails with a cryptic error:

[23:17:49.972] @reproduction/web:build: Run npm run preview to preview your production build locally.
[23:17:49.979] @reproduction/web:build: 
[23:17:49.979] @reproduction/web:build: > Using @sveltejs/adapter-vercel
[23:17:52.958] @reproduction/web:build: error during build:
[23:17:52.958] @reproduction/web:build: Error: Failed to parse /usr/bin/ldd as script:
[23:17:52.959] @reproduction/web:build: Unexpected character ' ' (1:1)
[23:17:52.959] @reproduction/web:build:     at Object.analyze [as default] (/vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/analyze.js:223:30)
[23:17:52.959] @reproduction/web:build:     at Job.emitDependency (/vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:281:52)
[23:17:52.959] @reproduction/web:build:     at async /vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:292:21
[23:17:52.959] @reproduction/web:build:     at async Promise.all (index 0)
[23:17:52.959] @reproduction/web:build:     at async Job.emitDependency (/vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:287:9)
[23:17:52.960] @reproduction/web:build:     at async /vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:316:21
[23:17:52.961] @reproduction/web:build:     at async Promise.all (index 2)
[23:17:52.961] @reproduction/web:build:     at async Job.emitDependency (/vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:287:9)
[23:17:52.961] @reproduction/web:build:     at async /vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:316:21
[23:17:52.961] @reproduction/web:build:     at async Promise.all (index 1)
[23:17:52.978] @reproduction/web:build:  ELIFECYCLE  Command failed with exit code 1.
[23:17:52.987] @reproduction/web:build: ERROR: command finished with error: command (web) pnpm run build exited (1)
[23:17:52.988] command (web) pnpm run build exited (1)
[23:17:52.988] 
[23:17:52.988]  Tasks:    1 successful, 2 total
[23:17:52.988] Cached:    0 cached, 2 total
[23:17:52.988]   Time:    21.224s 
[23:17:52.989] 
[23:17:52.993]  ELIFECYCLE  Command failed with exit code 1.
[23:17:53.097] Error: Command "cd .. && pnpm build" exited with 1

Same portion of logs when building locally:

@reproduction/web:build: Run npm run preview to preview your production build locally.
@reproduction/web:build: 
@reproduction/web:build: > Using @sveltejs/adapter-vercel
@reproduction/web:build:   The following modules failed to locate dependencies that may (or may not) be required for your app to work:
@reproduction/web:build:   ../node_modules/.pnpm/mongodb@4.5.0/node_modules/mongodb/lib/bson.js
@reproduction/web:build:     - bson-ext
@reproduction/web:build:   ../node_modules/.pnpm/mongodb@4.5.0/node_modules/mongodb/lib/deps.js
@reproduction/web:build:     - snappy
@reproduction/web:build:     - aws4
@reproduction/web:build:     - snappy/package.json
@reproduction/web:build:     - kerberos
@reproduction/web:build:   ../node_modules/.pnpm/mongodb@4.5.0/node_modules/mongodb/lib/encrypter.js
@reproduction/web:build:     - mongodb-client-encryption
@reproduction/web:build:   ../node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/index.js
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.android-arm64.node
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.win32-ia32-msvc.node
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.win32-arm64-msvc.node
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.darwin-x64.node
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.darwin-arm64.node
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.freebsd-x64.node
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.win32-x64-msvc.node
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.linux-x64-musl.node
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.linux-x64-gnu.node
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.linux-arm64-gnu.node
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.linux-arm-gnueabihf.node
@reproduction/web:build:     - /Users/cryptodeal/adapter-vercel-build-error/node_modules/.pnpm/@napi-rs+pinyin@1.7.0/node_modules/@napi-rs/pinyin/pinyin.linux-arm64-musl.node
@reproduction/web:build:     - @napi-rs/pinyin-darwin-x64
@reproduction/web:build:     - @napi-rs/pinyin-android-arm64
@reproduction/web:build:     - @napi-rs/pinyin-linux-x64-gnu
@reproduction/web:build:     - @napi-rs/pinyin-win32-x64-msvc
@reproduction/web:build:     - @napi-rs/pinyin-linux-x64-musl
@reproduction/web:build:     - @napi-rs/pinyin-freebsd-x64
@reproduction/web:build:     - @napi-rs/pinyin-win32-ia32-msvc
@reproduction/web:build:     - @napi-rs/pinyin-linux-arm64-gnu
@reproduction/web:build:     - @napi-rs/pinyin-win32-arm64-msvc
@reproduction/web:build:     - @napi-rs/pinyin-linux-arm-gnueabihf
@reproduction/web:build:     - @napi-rs/pinyin-linux-arm64-musl
@reproduction/web:build:   ✔ done

 Tasks:    2 successful, 2 total
Cached:    0 cached, 2 total
  Time:    11.683s 

The same project w/o any changes, but using pinned version @sveltejs/adapter-vercel@1.0.0-next.62 deploys successfully (without the nice cleaned up build output ://).

I've linked a reproduction which has version @sveltejs/adapter-vercel@1.0.0-next.63 and build fails. Additionally, I've copied the log files from the failed build on Vercel using 1.0.0-next.63 in it's entirety.

I've also previously deployed a version to Vercel in the same repo using 1.0.0-next.62 (no other file changes), which built/deployed to Vercel without issue; the build logs for this working deployment using 1.0.0-next.62 can be found here.

Reproduction

https://github.com/cryptodeal/adapter-vercel-build-error

Logs

[23:17:16.772] Cloning github.com/cryptodeal/adapter-vercel-build-error (Branch: main, Commit: 1ce1f08)
[23:17:17.413] Cloning completed: 641.608ms
[23:17:17.788] Looking up build cache...
[23:17:17.911] Build Cache not found
[23:17:18.209] Running "vercel build"
[23:17:18.804] Vercel CLI 27.1.4
[23:17:19.159] Detected `pnpm-lock.yaml` generated by pnpm 7...
[23:17:19.171] Installing dependencies...
[23:17:19.861] Scope: all 3 workspace projects
[23:17:19.977] ..                                       | Progress: resolved 1, reused 0, downloaded 0, added 0
[23:17:20.130] ..                                       | +440 ++++++++++++++++++++++++++++++++
[23:17:20.628] Packages are hard linked from the content-addressable store to the virtual store.
[23:17:20.628]   Content-addressable store is at: /vercel/.local/share/pnpm/store/v3
[23:17:20.629]   Virtual store is at:             ../node_modules/.pnpm
[23:17:20.982] ..                                       | Progress: resolved 440, reused 0, downloaded 26, added 23
[23:17:21.988] ..                                       | Progress: resolved 440, reused 0, downloaded 70, added 70
[23:17:22.994] ..                                       | Progress: resolved 440, reused 0, downloaded 121, added 116
[23:17:23.999] ..                                       | Progress: resolved 440, reused 0, downloaded 213, added 211
[23:17:24.999] ..                                       | Progress: resolved 440, reused 0, downloaded 291, added 294
[23:17:26.000] ..                                       | Progress: resolved 440, reused 0, downloaded 382, added 387
[23:17:27.001] ..                                       | Progress: resolved 440, reused 0, downloaded 423, added 428
[23:17:28.003] ..                                       | Progress: resolved 440, reused 0, downloaded 429, added 434
[23:17:29.013] ..                                       | Progress: resolved 440, reused 0, downloaded 433, added 438
[23:17:29.686] .../node_modules/svelte-preprocess postinstall$ echo "[svelte-preprocess] Don't forget to install the preprocessors packages that will be used: node-sass/sass, stylus, less, postcss & postcss-load-config, coffeescript, pug, etc..."
[23:17:29.702] .../node_modules/svelte-preprocess postinstall: [svelte-preprocess] Don't forget to install the preprocessors packages that will be used: node-sass/sass, stylus, less, postcss & postcss-load-config, coffeescript, pug, etc...
[23:17:29.705] .../node_modules/svelte-preprocess postinstall: Done
[23:17:29.748] .../node_modules/@napi-rs/pinyin postinstall$ node postinstall.js
[23:17:29.759] .../esbuild@0.14.49/node_modules/esbuild postinstall$ node install.js
[23:17:29.759] .../.pnpm/turbo@1.3.1/node_modules/turbo postinstall$ node install.js
[23:17:29.836] .../node_modules/@napi-rs/pinyin postinstall: Done
[23:17:29.866] .../.pnpm/turbo@1.3.1/node_modules/turbo postinstall: Done
[23:17:29.879] .../esbuild@0.14.49/node_modules/esbuild postinstall: Done
[23:17:30.014] ..                                       | Progress: resolved 440, reused 0, downloaded 435, added 440, done
[23:17:30.499] 
[23:17:30.499] dependencies:
[23:17:30.499] + @fontsource/fira-mono 4.5.8
[23:17:30.500] + cookie 0.4.2
[23:17:30.500] 
[23:17:30.500] devDependencies:
[23:17:30.500] + @playwright/test 1.23.4
[23:17:30.500] + @reproduction/mongo 0.1.0 <- ../packages/mongo
[23:17:30.500] + @sveltejs/adapter-auto 1.0.0-next.61
[23:17:30.500] + @sveltejs/adapter-vercel 1.0.0-next.63
[23:17:30.501] + @sveltejs/kit 1.0.0-next.377
[23:17:30.501] + @types/cookie 0.5.1
[23:17:30.501] + @typescript-eslint/eslint-plugin 5.30.6
[23:17:30.501] + @typescript-eslint/parser 5.30.6
[23:17:30.501] + eslint 8.20.0
[23:17:30.501] + eslint-config-prettier 8.5.0
[23:17:30.501] + eslint-plugin-svelte3 4.0.0
[23:17:30.502] + prettier 2.7.1
[23:17:30.502] + prettier-plugin-svelte 2.7.0
[23:17:30.502] + svelte 3.49.0
[23:17:30.502] + svelte-check 2.8.0
[23:17:30.502] + svelte-preprocess 4.10.7
[23:17:30.502] + tslib 2.4.0
[23:17:30.504] + typescript 4.7.4
[23:17:30.504] + vite 3.0.0
[23:17:30.504] 
[23:17:30.505] . prepare$ svelte-kit sync
[23:17:30.826] . prepare: Done
[23:17:31.746] 
[23:17:31.746] > balleranalytics@0.1.0 build /vercel/path0
[23:17:31.746] > turbo run build
[23:17:31.746] 
[23:17:31.779] • Packages in scope: @reproduction/mongo, @reproduction/web
[23:17:31.779] • Running build in 2 packages
[23:17:31.779] • Remote computation caching enabled
[23:17:32.762] @reproduction/mongo:build: cache miss, executing 57d0fd0e906300ad
[23:17:33.391] @reproduction/mongo:build: 
[23:17:33.391] @reproduction/mongo:build: > @reproduction/mongo@0.1.0 build /vercel/path0/packages/mongo
[23:17:33.392] @reproduction/mongo:build: > mtgen ./src/db/models && tsup
[23:17:33.392] @reproduction/mongo:build: 
[23:17:34.871] @reproduction/mongo:build: Generating mongoose typescript definitions... done
[23:17:34.871] @reproduction/mongo:build: Writing interfaces to src/db/interfaces/mongoose.gen.ts
[23:17:35.452] @reproduction/mongo:build: Writing complete 🐒
[23:17:35.751] @reproduction/mongo:build: CLI Building entry: src/index.ts, src/db/interfaces/mongoose.gen.ts, src/db/models/Player.ts
[23:17:35.752] @reproduction/mongo:build: CLI Using tsconfig: tsconfig.json
[23:17:35.752] @reproduction/mongo:build: CLI tsup v6.1.3
[23:17:35.753] @reproduction/mongo:build: CLI Using tsup config: /vercel/path0/packages/mongo/tsup.config.ts
[23:17:35.756] @reproduction/mongo:build: CLI Target: node16
[23:17:35.763] @reproduction/mongo:build: CLI Cleaning output folder
[23:17:35.766] @reproduction/mongo:build: CJS Build start
[23:17:35.779] @reproduction/mongo:build: ESM Build start
[23:17:35.798] @reproduction/mongo:build: CJS ⚡️ Build success in 31ms
[23:17:35.868] @reproduction/mongo:build: ESM ⚡️ Build success in 89ms
[23:17:35.877] @reproduction/mongo:build: CJS dist/db/interfaces/mongoose.gen.js 188.00 B
[23:17:35.878] @reproduction/mongo:build: CJS dist/index.js                      284.00 B
[23:17:35.878] @reproduction/mongo:build: CJS dist/chunk-USSDQICR.js             416.00 B
[23:17:35.879] @reproduction/mongo:build: CJS dist/db/models/Player.js           178.00 B
[23:17:35.879] @reproduction/mongo:build: CJS dist/chunk-X4E5EI36.js             1.63 KB
[23:17:35.880] @reproduction/mongo:build: ESM dist/index.mjs                      139.00 B
[23:17:35.880] @reproduction/mongo:build: ESM dist/chunk-HVWGDIWW.mjs             170.00 B
[23:17:35.881] @reproduction/mongo:build: ESM dist/db/interfaces/mongoose.gen.mjs 84.00 B
[23:17:35.881] @reproduction/mongo:build: ESM dist/db/models/Player.mjs           74.00 B
[23:17:35.881] @reproduction/mongo:build: ESM dist/chunk-P2EC7ETP.mjs             1.31 KB
[23:17:36.264] @reproduction/mongo:build: DTS Build start
[23:17:45.130] @reproduction/mongo:build: DTS ⚡️ Build success in 8866ms
[23:17:45.131] @reproduction/mongo:build: DTS dist/index.d.ts                      319.00 B
[23:17:45.132] @reproduction/mongo:build: DTS dist/db/models/Player.d.ts           109.00 B
[23:17:45.132] @reproduction/mongo:build: DTS dist/db/interfaces/mongoose.gen.d.ts 7.26 KB
[23:17:45.839] @reproduction/web:build: cache miss, executing 2783822609349508
[23:17:46.480] @reproduction/web:build: 
[23:17:46.480] @reproduction/web:build: > @reproduction/web@0.0.1 build /vercel/path0/web
[23:17:46.481] @reproduction/web:build: > vite build
[23:17:46.481] @reproduction/web:build: 
[23:17:47.097] @reproduction/web:build: vite v3.0.0 building for production...
[23:17:47.132] @reproduction/web:build: transforming...
[23:17:49.061] @reproduction/web:build: ✓ 34 modules transformed.
[23:17:49.156] @reproduction/web:build: rendering chunks...
[23:17:49.199] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/svelte-logo-87df40b8.svg                           1.85 KiB
[23:17:49.200] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/fira-mono-cyrillic-ext-400-normal-3df7909e.woff2   15.40 KiB
[23:17:49.200] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/fira-mono-cyrillic-400-normal-c7d433fd.woff2       8.89 KiB
[23:17:49.200] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/fira-mono-greek-ext-400-normal-9e2fe623.woff2      7.33 KiB
[23:17:49.200] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/fira-mono-greek-400-normal-a8be01ce.woff2          10.27 KiB
[23:17:49.201] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/fira-mono-latin-ext-400-normal-6bfabd30.woff2      11.10 KiB
[23:17:49.201] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/fira-mono-latin-400-normal-e43b3538.woff2          15.90 KiB
[23:17:49.201] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/fira-mono-all-400-normal-1e3b098c.woff             75.55 KiB
[23:17:49.205] @reproduction/web:build: .svelte-kit/output/client/_app/manifest.json                                                       5.86 KiB
[23:17:49.209] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/error.svelte-deed209b.js                                  1.56 KiB / gzip: 0.74 KiB
[23:17:49.210] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/pages/__layout.svelte-71f816a4.js                         4.77 KiB / gzip: 1.86 KiB
[23:17:49.210] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/pages/about.svelte-17b77763.js                            2.51 KiB / gzip: 1.15 KiB
[23:17:49.210] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/start-950cb5f3.js                                         23.66 KiB / gzip: 8.83 KiB
[23:17:49.210] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/pages/index.svelte-e9bdc351.js                            5.47 KiB / gzip: 2.43 KiB
[23:17:49.211] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/pages/todos/index.svelte-931c528e.js                      6.86 KiB / gzip: 2.88 KiB
[23:17:49.211] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/chunks/index-3541bec6.js                                  0.43 KiB / gzip: 0.30 KiB
[23:17:49.211] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/chunks/index-bf39200f.js                                  11.80 KiB / gzip: 5.02 KiB
[23:17:49.211] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/chunks/singletons-cdeec3fd.js                             0.05 KiB / gzip: 0.07 KiB
[23:17:49.212] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/index-8bad58d3.css                                 1.45 KiB / gzip: 0.52 KiB
[23:17:49.212] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/about-9682aba9.css                                 0.11 KiB / gzip: 0.10 KiB
[23:17:49.213] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/__layout-f74aac7c.css                              5.08 KiB / gzip: 1.56 KiB
[23:17:49.214] @reproduction/web:build: .svelte-kit/output/client/_app/immutable/assets/index-5c3529b5.css                                 3.70 KiB / gzip: 1.03 KiB
[23:17:49.230] @reproduction/web:build: vite v3.0.0 building SSR bundle for production...
[23:17:49.239] @reproduction/web:build: transforming...
[23:17:49.860] @reproduction/web:build: ✓ 35 modules transformed.
[23:17:49.896] @reproduction/web:build: rendering chunks...
[23:17:49.920] @reproduction/web:build: .svelte-kit/output/server/manifest.json                         2.37 KiB
[23:17:49.921] @reproduction/web:build: .svelte-kit/output/server/index.js                              76.18 KiB
[23:17:49.921] @reproduction/web:build: .svelte-kit/output/server/entries/endpoints/todos/index.ts.js   1.45 KiB
[23:17:49.921] @reproduction/web:build: .svelte-kit/output/server/entries/pages/__layout.svelte.js      4.63 KiB
[23:17:49.921] @reproduction/web:build: .svelte-kit/output/server/entries/fallbacks/error.svelte.js     0.74 KiB
[23:17:49.921] @reproduction/web:build: .svelte-kit/output/server/entries/pages/about.svelte.js         1.40 KiB
[23:17:49.922] @reproduction/web:build: .svelte-kit/output/server/entries/pages/index.svelte.js         8.23 KiB
[23:17:49.922] @reproduction/web:build: .svelte-kit/output/server/entries/pages/todos/index.svelte.js   5.94 KiB
[23:17:49.922] @reproduction/web:build: .svelte-kit/output/server/immutable/chunks/index-615dd153.js    4.15 KiB
[23:17:49.922] @reproduction/web:build: .svelte-kit/output/server/immutable/chunks/hooks-d9fcff81.js    0.46 KiB
[23:17:49.962] @reproduction/web:build: (node:550) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time
[23:17:49.962] @reproduction/web:build: (Use `node --trace-warnings ...` to show where the warning was created)
[23:17:49.972] @reproduction/web:build: 
[23:17:49.972] @reproduction/web:build: Run npm run preview to preview your production build locally.
[23:17:49.979] @reproduction/web:build: 
[23:17:49.979] @reproduction/web:build: > Using @sveltejs/adapter-vercel
[23:17:52.958] @reproduction/web:build: error during build:
[23:17:52.958] @reproduction/web:build: Error: Failed to parse /usr/bin/ldd as script:
[23:17:52.959] @reproduction/web:build: Unexpected character ' ' (1:1)
[23:17:52.959] @reproduction/web:build:     at Object.analyze [as default] (/vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/analyze.js:223:30)
[23:17:52.959] @reproduction/web:build:     at Job.emitDependency (/vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:281:52)
[23:17:52.959] @reproduction/web:build:     at async /vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:292:21
[23:17:52.959] @reproduction/web:build:     at async Promise.all (index 0)
[23:17:52.959] @reproduction/web:build:     at async Job.emitDependency (/vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:287:9)
[23:17:52.960] @reproduction/web:build:     at async /vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:316:21
[23:17:52.961] @reproduction/web:build:     at async Promise.all (index 2)
[23:17:52.961] @reproduction/web:build:     at async Job.emitDependency (/vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:287:9)
[23:17:52.961] @reproduction/web:build:     at async /vercel/path0/node_modules/.pnpm/@vercel+nft@0.20.1/node_modules/@vercel/nft/out/node-file-trace.js:316:21
[23:17:52.961] @reproduction/web:build:     at async Promise.all (index 1)
[23:17:52.978] @reproduction/web:build:  ELIFECYCLE  Command failed with exit code 1.
[23:17:52.987] @reproduction/web:build: ERROR: command finished with error: command (web) pnpm run build exited (1)
[23:17:52.988] command (web) pnpm run build exited (1)
[23:17:52.988] 
[23:17:52.988]  Tasks:    1 successful, 2 total
[23:17:52.988] Cached:    0 cached, 2 total
[23:17:52.988]   Time:    21.224s 
[23:17:52.989] 
[23:17:52.993]  ELIFECYCLE  Command failed with exit code 1.
[23:17:53.097] Error: Command "cd .. && pnpm build" exited with 1

System Info

System:
    OS: macOS 12.3.1
    CPU: (8) arm64 Apple M1
    Memory: 81.58 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.3.0 - ~/.nvm/versions/node/v18.3.0/bin/node
    Yarn: 1.22.18 - /opt/homebrew/bin/yarn
    npm: 8.12.2 - ~/.nvm/versions/node/v18.3.0/bin/npm
  Browsers:
    Brave Browser: 103.1.40.107
    Chrome: 103.0.5060.114
    Firefox: 101.0
    Safari: 15.4
    Safari Technology Preview: 16.0

Severity

blocking an upgrade

Additional Information

Using SvelteKit in BallerAnalytics, a basketball analytics/fantasy insight platform, this blocks an upgrade.

Have worked around by pinning @sveltejs/adapter-vercel@1.0.0-next.62 for the time being, but ultimately will prevent upgrading to latest version of adapter Vercel.

Additionally, Googling vercel "usr/bin/ldd" produces only 2 results, one of which references @napi-rs, which is one of the dependencies listed in the errors that were displayed prior to the update released in version 1.0.0-next.63.

Rich-Harris commented 2 years ago

The immediate cause is that as of #5551, errors during dependency tracing (adapter-vercel uses @vercel/nft to figure out which modules to include in the generated lambda) are thrown, rather than just printing gibberish to the terminal:

https://github.com/sveltejs/kit/blob/5b2dda42843f6a9776e0e11da1780cebbe11910f/packages/adapter-vercel/index.js#L311-L322

It didn't occur to me that this would break apps that were otherwise functional. With my degree from the University of Google I can tell you that ldd is a utility found on Linux but not MacOS, which at least partly explains why it's building locally but not on Vercel, but I'm not qualified to actually fix it.

Going back to printing errors instead of throwing them would presumably fix this case, but it doesn't feel like the right long term solution. It feels like it might be a bug in nft (presumably it shouldn't be trying to parse a binary file), so I think that's the place we should investigate.

cryptodeal commented 2 years ago

Agree, would prefer to have best of both worlds in terms of the nicely cleaned up error logs & working builds; thanks for pointing me in the right direction! I've opened an issue in the @vercel/nft repo with the relevant info/links.

styfle commented 2 years ago

Going back to printing errors instead of throwing them would presumably fix this case

Yes that is the correct solution. The warnings from nft are not errors, they are warnings.

https://github.com/sveltejs/kit/blob/5b2dda42843f6a9776e0e11da1780cebbe11910f/packages/adapter-vercel/index.js#L307

Rich-Harris commented 2 years ago

@styfle is it right that nft is trying to parse /usr/bin/ldd as a script? It does seem a bit odd just to disregard errors like this. Are there any warnings that are unsafe to ignore?

I think part of my confusion stemmed from the fact that the type of traced.warnings is Error[], with stack traces pointing at nft internals. I wonder if they should just be objects?

styfle commented 2 years ago

is it right that nft is trying to parse /usr/bin/ldd as a script

Could be. I'm guessing something is attempting to read that file so nft trys to trace it. Which module is it coming from?

styfle commented 2 years ago

Are there any warnings that are unsafe to ignore?

I would argue all of them are safe to ignore. Imagine something like optionalDependencies where the module checks for existence with try { require('some-pkg') } catch { }. This will be traced by nft but might be missing and missing might be okay.

Rich-Harris commented 2 years ago

I'm guessing something is attempting to read that file so nft trys to trace it. Which module is it coming from?

It's coming from here and here. In both cases it's a readFileSync, which I wouldn't expect to result in nft attempting to parse the contents, but maybe it does that for a reason?

Rich-Harris commented 2 years ago

Thinking about this further: it makes sense that optional dependencies would result in a warning (that's what #5551 was about). But if nft fails to parse a script, that feels like an error that should be treated as such — either the inputs are bad in a way that means the resulting app will likely suffer runtime failures, or nft is treating something as an input that probably shouldn't be considered an input.

styfle commented 2 years ago

In both cases it's a readFileSync, which I wouldn't expect to result in nft attempting to parse the contents, but maybe it does that for a reason?

Yeah it is a bit strange now that I think about it. We should parse import but probably not readFile. However, removing the behavior causes several tests to fail https://github.com/vercel/nft/pull/304

Rich-Harris commented 2 years ago

Going to close this now that @vercel/nft@0.22 has been released — thanks @styfle!

styfle commented 2 years ago

@Rich-Harris We had to revert that change because it caused more bugs.

After further analysis, the real issue is that adatper is not setting the base directory properly (looks like its effectively setting base: '/') instead of the user's working directory.

https://github.com/sveltejs/kit/blob/5b2dda42843f6a9776e0e11da1780cebbe11910f/packages/adapter-vercel/index.js#L300

blazzjosh commented 2 years ago

My build is failing....Screen Shot 2022-09-14 at 1 15 08 AM

blazzjosh commented 2 years ago

Is there any workaround?

@Rich-Harris We had to revert that change because it caused more bugs.

After further analysis, the real issue is that adatper is not setting the base directory properly (looks like its effectively setting base: '/') instead of the user's working directory.

i> https://github.com/sveltejs/kit/blob/5b2dda42843f6a9776e0e11da1780cebbe11910f/packages/adapter-vercel/index.js#L300

Rich-Harris commented 2 years ago

@styfle Can you elaborate? base isn't supposed to be the user's working directory, it's supposed to be the root directory — IIRC it was failing to trace stuff outside base (e.g. in a workspace root, or in a linked package when testing locally), so we have to be able to guarantee that every file is inside base. We then find the common ancestor:

https://github.com/sveltejs/kit/blob/5b2dda42843f6a9776e0e11da1780cebbe11910f/packages/adapter-vercel/index.js#L357

I think we have to pin 0.22.0 until we can find an alternative approach, since 0.22.1 is causing build failures.

styfle commented 2 years ago

@Rich-Harris The base should be the monorepo root.

You can use repoRootPath provided to the Builder/Runtime to detect this like so:

https://github.com/vercel/vercel/blob/b8110d97d10cb59251355fa01e8095c2761285d1/packages/node/src/index.ts#L372

Otherwise, you could try to detect workspaces the same way yarn/npm/pnpm does to find the monorepo root.