Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodeFileTrace Chokes on @napi-rs Dependency usr/bin/ldd, Causing Build to Fail #303

Closed
cryptodeal opened this issue Jul 18, 2022 · 1 comment · Fixed by #304
Closed

nodeFileTrace Chokes on @napi-rs Dependency usr/bin/ldd, Causing Build to Fail #303

cryptodeal opened this issue Jul 18, 2022 · 1 comment · Fixed by #304

Comments

@cryptodeal
Copy link

As of @sveltejs/adapter-vercel version 1.0.0-next.63, the build process employs the exported nodeFileTrace function from @vercel/nft to determine which modules throw errors, allowing the errors logged by the CLI to be displayed in a much cleaner manner.

Unfortunately, this causes the build to error out:

[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: �[36mvite v3.0.0 �[32mbuilding for production...�[36m�[39m
[23:17:47.132] @reproduction/web:build: transforming...
[23:17:49.061] @reproduction/web:build: �[32m✓�[39m 34 modules transformed.
[23:17:49.156] @reproduction/web:build: rendering chunks...
[23:17:49.199] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[32mimmutable/assets/svelte-logo-87df40b8.svg                          �[39m �[2m1.85 KiB�[22m
[23:17:49.200] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[32mimmutable/assets/fira-mono-cyrillic-ext-400-normal-3df7909e.woff2  �[39m �[2m15.40 KiB�[22m
[23:17:49.200] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[32mimmutable/assets/fira-mono-cyrillic-400-normal-c7d433fd.woff2      �[39m �[2m8.89 KiB�[22m
[23:17:49.200] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[32mimmutable/assets/fira-mono-greek-ext-400-normal-9e2fe623.woff2     �[39m �[2m7.33 KiB�[22m
[23:17:49.200] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[32mimmutable/assets/fira-mono-greek-400-normal-a8be01ce.woff2         �[39m �[2m10.27 KiB�[22m
[23:17:49.201] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[32mimmutable/assets/fira-mono-latin-ext-400-normal-6bfabd30.woff2     �[39m �[2m11.10 KiB�[22m
[23:17:49.201] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[32mimmutable/assets/fira-mono-latin-400-normal-e43b3538.woff2         �[39m �[2m15.90 KiB�[22m
[23:17:49.201] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[32mimmutable/assets/fira-mono-all-400-normal-1e3b098c.woff            �[39m �[2m75.55 KiB�[22m
[23:17:49.205] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[32mmanifest.json                                                      �[39m �[2m5.86 KiB�[22m
[23:17:49.209] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[36mimmutable/error.svelte-deed209b.js                                 �[39m �[2m1.56 KiB / gzip: 0.74 KiB�[22m
[23:17:49.210] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[36mimmutable/pages/__layout.svelte-71f816a4.js                        �[39m �[2m4.77 KiB / gzip: 1.86 KiB�[22m
[23:17:49.210] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[36mimmutable/pages/about.svelte-17b77763.js                           �[39m �[2m2.51 KiB / gzip: 1.15 KiB�[22m
[23:17:49.210] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[36mimmutable/start-950cb5f3.js                                        �[39m �[2m23.66 KiB / gzip: 8.83 KiB�[22m
[23:17:49.210] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[36mimmutable/pages/index.svelte-e9bdc351.js                           �[39m �[2m5.47 KiB / gzip: 2.43 KiB�[22m
[23:17:49.211] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[36mimmutable/pages/todos/index.svelte-931c528e.js                     �[39m �[2m6.86 KiB / gzip: 2.88 KiB�[22m
[23:17:49.211] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[36mimmutable/chunks/index-3541bec6.js                                 �[39m �[2m0.43 KiB / gzip: 0.30 KiB�[22m
[23:17:49.211] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[36mimmutable/chunks/index-bf39200f.js                                 �[39m �[2m11.80 KiB / gzip: 5.02 KiB�[22m
[23:17:49.211] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[36mimmutable/chunks/singletons-cdeec3fd.js                            �[39m �[2m0.05 KiB / gzip: 0.07 KiB�[22m
[23:17:49.212] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[35mimmutable/assets/index-8bad58d3.css                                �[39m �[2m1.45 KiB / gzip: 0.52 KiB�[22m
[23:17:49.212] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[35mimmutable/assets/about-9682aba9.css                                �[39m �[2m0.11 KiB / gzip: 0.10 KiB�[22m
[23:17:49.213] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[35mimmutable/assets/__layout-f74aac7c.css                             �[39m �[2m5.08 KiB / gzip: 1.56 KiB�[22m
[23:17:49.214] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/client/_app/�[22m�[90m�[39m�[35mimmutable/assets/index-5c3529b5.css                                �[39m �[2m3.70 KiB / gzip: 1.03 KiB�[22m
[23:17:49.230] @reproduction/web:build: �[36mvite v3.0.0 �[32mbuilding SSR bundle for production...�[36m�[39m
[23:17:49.239] @reproduction/web:build: transforming...
[23:17:49.860] @reproduction/web:build: �[32m✓�[39m 35 modules transformed.
[23:17:49.896] @reproduction/web:build: rendering chunks...
[23:17:49.920] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/server/�[22m�[90m�[39m�[32mmanifest.json                        �[39m �[2m2.37 KiB�[22m
[23:17:49.921] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/server/�[22m�[90m�[39m�[36mindex.js                             �[39m �[2m76.18 KiB�[22m
[23:17:49.921] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/server/�[22m�[90m�[39m�[36mentries/endpoints/todos/index.ts.js  �[39m �[2m1.45 KiB�[22m
[23:17:49.921] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/server/�[22m�[90m�[39m�[36mentries/pages/__layout.svelte.js     �[39m �[2m4.63 KiB�[22m
[23:17:49.921] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/server/�[22m�[90m�[39m�[36mentries/fallbacks/error.svelte.js    �[39m �[2m0.74 KiB�[22m
[23:17:49.921] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/server/�[22m�[90m�[39m�[36mentries/pages/about.svelte.js        �[39m �[2m1.40 KiB�[22m
[23:17:49.922] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/server/�[22m�[90m�[39m�[36mentries/pages/index.svelte.js        �[39m �[2m8.23 KiB�[22m
[23:17:49.922] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/server/�[22m�[90m�[39m�[36mentries/pages/todos/index.svelte.js  �[39m �[2m5.94 KiB�[22m
[23:17:49.922] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/server/�[22m�[90m�[39m�[36mimmutable/chunks/index-615dd153.js   �[39m �[2m4.15 KiB�[22m
[23:17:49.922] @reproduction/web:build: �[90m�[37m�[2m.svelte-kit/output/server/�[22m�[90m�[39m�[36mimmutable/chunks/hooks-d9fcff81.js   �[39m �[2m0.46 KiB�[22m
[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: �[31merror 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)�[39m
[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

Per @Rich-Harris, this appears to possibly be an issue within the exported nodeFileTrace function in @vercel/nft as it appears to be attempting to parse usr/bin/ldd: sveltejs/kit#5577 (comment)

Link to the full initial issue w/ additional logs: sveltejs/kit#5577

Link to reproduction of issue: https://github.com/cryptodeal/adapter-vercel-build-error

@styfle
Copy link
Member

styfle commented Jul 18, 2022

I suspect napi-rs is attempting to read that file which is why nft attempts to trace it.

Without the repo with the input file and nft options, I can't know for sure.

However, this isn't really a bug in nft. The warnings in the result from nft can be handled as you wish, and it seems svelte decided to throw.

@styfle styfle closed this as completed Jul 18, 2022
styfle added a commit that referenced this issue Aug 22, 2022
This PR changes the behavior of dependency tracing such that `fs.readFile('./file.js')` is no longer considered a `dependency` and it will not be traced. Instead, it is considered an `asset` the same way a `fs.readFile('./file.txt')` is. The `dependency` type will be reserved for `import` and `require` only.

- Fixes #303 
- Related to vercel/customer-issues#608

Note that this could be considered a breaking change since #40 expected the `readFile()`  config to be called for assets but it should only be called for dependencies.

In order to reduce the amount of breakage, `require.resolve()` was left as dependency instead of asset since its often passed to `child_process.spawn()` which needs the dependencies.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants