vercel / turbo

Incremental bundler and build system optimized for JavaScript and TypeScript, written in Rust – including Turbopack and Turborepo.
https://turbo.build
MIT License
25.68k stars 1.75k forks source link

[turborepo] next.js cache misses on Vercel without doing any changes #3362

Closed marwenguesmii closed 5 months ago

marwenguesmii commented 1 year ago

What version of Turborepo are you using?

1.7.0

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Mac

Describe the Bug

Hello I am running next.js 13 deployment on Vercel and everytime I redeploy the project, the task next build changes its hash even If I didn't change anything. I thought maybe its because of system environnement variables created by Vercel ( NEXT_PUBLIC_VERCEL_*) but its not. Because Vercel eliminates these variables from the hash cache compute by setting this TURBO_CI_VENDOR_ENV_KEY=NEXT_PUBLIC_VERCEL_. Locally, it's always the same hash so I think its a problem related to the CI environnement.

Expected Behavior

I expect the task hash to remain the same

To Reproduce

I don't know actually how to reproduce this

Reproduction Repo

No response

tknickman commented 1 year ago

Hey @Marwennnne, could you post your turbo.json, and pass -vvv to turbo when deploying on Vercel so we can take a look at your debug logs? Then either post a link to your deployment here, or a copy of the build logs.

marwenguesmii commented 1 year ago

Hey @tknickman

Vercel Build logs:

[17:47:08.196] Retrieving list of deployment files...
[17:47:09.155] Downloading 2016 deployment files...
[17:49:20.521] Restored build cache
[17:49:20.580] Running "vercel build"
[17:49:21.192] Vercel CLI 28.12.7
[17:49:25.900] > Automatically detected Turbo monorepo manager. Attempting to assign default settings.
[17:49:25.901] WARN! Cannot automatically assign buildCommand as it is already set via project settings or configuration overrides.
[17:49:25.901] WARN! Cannot automatically assign installCommand as it is already set via project settings or configuration overrides.
[17:49:26.275] Detected `pnpm-lock.yaml` generated by pnpm 7...
[17:49:26.292] Running "install" command: `bash vercel-install.sh`...
[17:49:26.462] + cd ../..
[17:49:26.463] + pnpm install --filter @outmind/outmind --filter @outmind/app-web... --frozen-lockfile --strict-peer-dependencies
[17:49:29.117] Scope: 8 of 40 workspace projects
[17:49:29.350] Lockfile is up to date, resolution step is skipped
[17:49:29.549] Progress: resolved 1, reused 0, downloaded 0, added 0
[17:49:29.685] .                                        |  +11 +
[17:49:30.551] Progress: resolved 11, reused 0, downloaded 9, added 10
[17:49:44.362] Progress: resolved 11, reused 0, downloaded 10, added 10
[17:49:45.378] Progress: resolved 11, reused 0, downloaded 10, added 11, done
[17:49:45.484] . prepare$ husky install
[17:49:45.678] . prepare: fatal: not a git repository (or any of the parent directories): .git
[17:49:45.681] . prepare: Done
[17:49:45.684] Done in 19.1s
[17:49:45.704] Detected Next.js version: 13.0.6
[17:49:45.811] Running "bash vercel-build.sh"
[17:49:45.819] + cd ../..
[17:49:45.819] + export TURBO_CI_VENDOR_ENV_KEY=NEXT_PUBLIC_VERCEL_
[17:49:45.819] + TURBO_CI_VENDOR_ENV_KEY=NEXT_PUBLIC_VERCEL_
[17:49:45.832] + pnpm run build --scope=@outmind/app-web --include-dependencies -vvv
[17:49:46.517] 
[17:49:46.518] > @outmind/outmind@ build /vercel/path0
[17:49:46.518] > turbo run build "--scope=@outmind/app-web" "--include-dependencies" "-vvv"
[17:49:46.518] 
[17:49:46.532] 2023-01-18T16:49:46.532+0000 [DEBUG] turborepo_lib::shim: Running local turbo binary in /vercel/path0/node_modules/.bin/turbo
[17:49:46.532] 
[17:49:46.933]  WARNING  cannot find a .git folder. Falling back to manual file hashing (which may be slower). If you are running this build in a pruned directory, you can ignore this message. Otherwise, please initialize a git repository in the root of your monorepo
[17:49:48.621] • Packages in scope: @outmind/app-web, @outmind/ebo, @outmind/eslint-config, @outmind/helpers, @outmind/sdk, @outmind/types, @outmind/ui-elements
[17:49:48.621] • Running build in 7 packages
[17:49:48.622] • Remote caching enabled
[17:49:48.641] @outmind/types:build: cache hit, replaying output cd73fe7011424779
[17:49:48.641] @outmind/types:build: 
[17:49:48.642] @outmind/types:build: > @outmind/types@ build /vercel/path0/libraries/types
[17:49:48.642] @outmind/types:build: > pnpm clean && tsc
[17:49:48.642] @outmind/types:build: 
[17:49:48.642] @outmind/types:build: 
[17:49:48.642] @outmind/types:build: > @outmind/types@ clean /vercel/path0/libraries/types
[17:49:48.642] @outmind/types:build: > rm -rf build
[17:49:48.642] @outmind/types:build: 
[17:49:48.647] @outmind/helpers:build: cache hit, replaying output 0531aa341a6d1ad1
[17:49:48.647] @outmind/helpers:build: 
[17:49:48.647] @outmind/helpers:build: > @outmind/helpers@ build /vercel/path0/libraries/helpers
[17:49:48.647] @outmind/helpers:build: > pnpm clean && tsc
[17:49:48.647] @outmind/helpers:build: 
[17:49:48.649] @outmind/helpers:build: 
[17:49:48.649] @outmind/helpers:build: > @outmind/helpers@ clean /vercel/path0/libraries/helpers
[17:49:48.649] @outmind/helpers:build: > rm -rf build
[17:49:48.649] @outmind/helpers:build: 
[17:49:48.650] @outmind/ebo:build: cache hit, replaying output 636020e869088e50
[17:49:48.650] @outmind/ebo:build: 
[17:49:48.650] @outmind/ebo:build: > @outmind/ebo@0.0.0 build /vercel/path0/libraries/ebo
[17:49:48.650] @outmind/ebo:build: > pnpm clean && tsc
[17:49:48.650] @outmind/ebo:build: 
[17:49:48.650] @outmind/ebo:build: 
[17:49:48.650] @outmind/ebo:build: > @outmind/ebo@0.0.0 clean /vercel/path0/libraries/ebo
[17:49:48.651] @outmind/ebo:build: > rm -rf build
[17:49:48.651] @outmind/ebo:build: 
[17:49:48.653] @outmind/sdk:build: cache hit, replaying output 0a4312129827c8ef
[17:49:48.653] @outmind/sdk:build: 
[17:49:48.653] @outmind/sdk:build: > @outmind/sdk@0.0.0 build /vercel/path0/libraries/sdk
[17:49:48.653] @outmind/sdk:build: > pnpm clean && tsc
[17:49:48.653] @outmind/sdk:build: 
[17:49:48.654] @outmind/sdk:build: 
[17:49:48.654] @outmind/sdk:build: > @outmind/sdk@0.0.0 clean /vercel/path0/libraries/sdk
[17:49:48.654] @outmind/sdk:build: > rm -rf build
[17:49:48.654] @outmind/sdk:build: 
[17:49:48.654] @outmind/ui-elements:build: cache hit, replaying output 329d3a8923e69cef
[17:49:48.655] @outmind/ui-elements:build: 
[17:49:48.655] @outmind/ui-elements:build: > @outmind/ui-elements@ build /vercel/path0/libraries/ui-elements
[17:49:48.655] @outmind/ui-elements:build: > pnpm run typecheck
[17:49:48.655] @outmind/ui-elements:build: 
[17:49:48.655] @outmind/ui-elements:build: 
[17:49:48.655] @outmind/ui-elements:build: > @outmind/ui-elements@ typecheck /vercel/path0/libraries/ui-elements
[17:49:48.655] @outmind/ui-elements:build: > tsc --noEmit
[17:49:48.656] @outmind/ui-elements:build: 
[17:49:48.929] @outmind/app-web:build: cache miss, executing 9128847740a3c4bf
[17:49:49.631] @outmind/app-web:build: 
[17:49:49.631] @outmind/app-web:build: > @outmind/app-web@ build /vercel/path0/apps/app-web
[17:49:49.632] @outmind/app-web:build: > next build
[17:49:49.632] @outmind/app-web:build: 
[17:49:50.029] @outmind/app-web:build: info  - Loaded env from /vercel/path0/apps/app-web/.env
[17:49:50.395] @outmind/app-web:build: info  - Linting and checking validity of types...
[17:49:53.399] @outmind/app-web:build: warn  - The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config
[17:50:16.345] @outmind/app-web:build: info  - Creating an optimized production build...
[17:50:57.852] @outmind/app-web:build: warn  - Compiled with warnings
[17:50:57.852] @outmind/app-web:build: 
[17:50:57.853] @outmind/app-web:build: ../../node_modules/.pnpm/debug@4.3.2/node_modules/debug/src/node.js
[17:50:57.853] @outmind/app-web:build: Module not found: ESM packages (supports-color) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals
[17:50:57.853] @outmind/app-web:build: 
[17:50:57.853] @outmind/app-web:build: Import trace for requested module:
[17:50:57.853] @outmind/app-web:build: ../../node_modules/.pnpm/debug@4.3.2/node_modules/debug/src/node.js
[17:50:57.853] @outmind/app-web:build: ../../node_modules/.pnpm/debug@4.3.2/node_modules/debug/src/index.js
[17:50:57.854] @outmind/app-web:build: ../../node_modules/.pnpm/follow-redirects@1.14.9_debug@4.3.2/node_modules/follow-redirects/debug.js
[17:50:57.854] @outmind/app-web:build: ../../node_modules/.pnpm/follow-redirects@1.14.9_debug@4.3.2/node_modules/follow-redirects/index.js
[17:50:57.854] @outmind/app-web:build: ../../node_modules/.pnpm/axios@0.26.1/node_modules/axios/lib/adapters/http.js
[17:50:57.854] @outmind/app-web:build: ../../node_modules/.pnpm/axios@0.26.1/node_modules/axios/lib/defaults/index.js
[17:50:57.854] @outmind/app-web:build: ../../node_modules/.pnpm/axios@0.26.1/node_modules/axios/lib/axios.js
[17:50:57.855] @outmind/app-web:build: ../../node_modules/.pnpm/axios@0.26.1/node_modules/axios/index.js
[17:50:57.855] @outmind/app-web:build: ../../libraries/ui-elements/src/hooks/useApiBridge/index.ts
[17:50:57.855] @outmind/app-web:build: ../../libraries/ui-elements/src/hooks/index.ts
[17:50:57.855] @outmind/app-web:build: ../../libraries/ui-elements/src/components/AcceptTerms/index.tsx
[17:50:57.855] @outmind/app-web:build: ../../libraries/ui-elements/src/components/index.ts
[17:50:57.855] @outmind/app-web:build: ../../libraries/ui-elements/src/index.ts
[17:50:57.856] @outmind/app-web:build: 
[17:50:57.856] @outmind/app-web:build: info  - Collecting page data...
[17:50:58.570] @outmind/app-web:build: info  - Generating static pages (0/3)
[17:50:58.862] @outmind/app-web:build: info  - Generating static pages (3/3)
[17:50:58.872] @outmind/app-web:build: info  - Finalizing page optimization...
[17:50:58.877] @outmind/app-web:build: 
[17:50:58.899] @outmind/app-web:build: Route (pages)                              Size     First Load JS
[17:50:58.900] @outmind/app-web:build: ┌ ○ /                                      84.6 kB         191 kB
[17:50:58.900] @outmind/app-web:build: └ ○ /404                                   184 B           106 kB
[17:50:58.900] @outmind/app-web:build: + First Load JS shared by all              106 kB
[17:50:58.900] @outmind/app-web:build:   ├ chunks/framework-ca29938ac7bc07b0.js   67 kB
[17:50:58.900] @outmind/app-web:build:   ├ chunks/main-8961722b929b6aef.js        36.7 kB
[17:50:58.900] @outmind/app-web:build:   ├ chunks/pages/_app-aaf241d127465868.js  198 B
[17:50:58.901] @outmind/app-web:build:   └ chunks/webpack-eef93431b169f83b.js     2.19 kB
[17:50:58.901] @outmind/app-web:build: 
[17:50:58.901] @outmind/app-web:build: ○  (Static)  automatically rendered as static HTML (uses no initial props)
[17:50:58.901] @outmind/app-web:build: 
[17:50:59.089] 
[17:50:59.090]  Tasks:    6 successful, 6 total
[17:50:59.090] Cached:    5 cached, 6 total
[17:50:59.090]   Time:    1m12.543s 
[17:50:59.090] 
[17:51:00.590] ...writing to cache...
[17:51:08.874] Collected static files (public/, static/, .next/static): 16.967ms
[17:51:09.033] Build Completed in /vercel/output [2m]
[17:51:10.126] Generated build outputs:
[17:51:10.127]  - Static files: 83
[17:51:10.127]  - Serverless Functions: 0
[17:51:10.127]  - Edge Functions: 0
[17:51:10.127] Deployed outputs in 1s
[17:51:10.551] Build completed. Populating build cache...
[17:54:51.838] Uploading build cache [590.66 MB]...
[17:55:17.523] Build cache uploaded: 25.684s

turbo.json:

{
  "$schema": "https://turborepo.org/schema.json",
  "pipeline": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": ["build/**", ".tsbuildinfo", "target/**", "index.node"]
    },
    "build:watch": {
      "cache": false
    },
    "clean": {
      "outputs": []
    },
    "dev": {
      "cache": false
    },
    "dist": {
      "dependsOn": ["build"]
    },
    "lint": {
      "outputs": []
    },
    "test": {
      "dependsOn": ["build"],
      "outputs": []
    },
    "typecheck": {
      "outputs": []
    }
  },
  "baseBranch": "origin/main",
  "globalDependencies": ["tsconfig.json", ".swcrc"]
}
mehulkar commented 1 year ago

Just making sure, have you added .turbo to your .gitignore?

marwenguesmii commented 1 year ago

@mehulkar Yes .turbo is written in the .gitignore. In fact, if it was not written I think it would affect all the tasks' hashes not only the next.js task no ?

anthonyshew commented 5 months ago

I think this is a stale by now. I do remember having this problem in the past but it hasn't been happening for me anymore for awhile. If you're still running into this, please open a new issue with reproduction steps!