vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.02k stars 1.79k forks source link

Fail to build on Vercel with completely inconsistent errors. #8610

Open igloo1505 opened 2 months ago

igloo1505 commented 2 months ago

Verify canary release

Link to code that reproduces this issue

https://github.com/igloo1505/ulld

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

pnpm

What operating system are you using?

Mac

Which canary version will you have in your reproduction?

turbo@2.0.6-canary.0

Describe the Bug

The app I'm trying to build on Vercel is part of a relatively large monorepo. The app itself is just the documentation site for a more complicated, although still fairly simple framework. The app was building fine on vercel, and still builds properly locally, but after taking a week or two to focus on writing documentation without adding any new dependencies, the build refuses to complete on Vercel. Over the past 3-4 days that I've been trying to get this to build, I've received probably 6 or 7 different error messages that don't seem to have any obvious correlation.

The original error I was getting was

. postinstall: Error: turbo_json_parse_error
. postinstall:   x Found an unknown key `tasks`.

This seemed to come out of nowhere after not building the app on vercel for maybe 10-12 days. There were no new dependencies added, but I did update Typescript to 5.5.2 and had briefly added a different package in the same monorepo to a git subtree. I've since removed that subtree trying to resolve this issue, and still am having no success.

The most common error I get is ERR_PNPM_EEXIST  EEXIST: file already exists, rename '/vercel/path0/node_modules/npm/node_modules' -> '/vercel/path0/node_modules/npm_tmp_179/node_modules', but I've also made it past the point where that error usually occurs, seemingly randomly, and received

...
@ulld/website:buildLocal:  ELIFECYCLE  Command failed with exit code 1.
@ulld/website:buildLocal: ERROR: command finished with error: command (/vercel/path0/apps/website) /vercel/path0/.vercel/cache/corepack/shim/pnpm run buildLocal exited (1)
@ulld/website#buildLocal: command (/vercel/path0/apps/website) /vercel/path0/.vercel/cache/corepack/shim/pnpm run buildLocal exited (1)
  Tasks:    1 successful, 2 total

Or this (admittedly, this one's probably on me alone). Changing pnpm version to match the version on Vercel and reinstalling resolved this.

ERR_PNPM_INCLUDED_DEPS_CONFLICT  modules directory (at "/vercel/path0") was installed with optionalDependencies, dependencies, devDependencies. Current install wants optionalDependencies, dependencies.

And then for a while, this:

Error: No more than 12 Serverless Functions can be added to a Deployment on the Hobby plan. Create a team (Pro plan) to deploy more. Learn More: https://vercel.link/function-count-limit

So far I've tried:

Expected Behavior

To build successfully, or at the least, produce a consistent error message that can point me to the source of the problem.

To Reproduce

I've provided a link to the repository above, and here as well. The /apps/website/ app is the one that I'm attempting to deploy on Vercel. Again, this was working previously with minimal issues.

Additional context

Deploying to Vercel, runs and builds without issue locally on Mac. Next is version 14.2.4.

chris-olszewski commented 2 months ago

Can you try deploying without the build cache? e.g. vc --force or setting VERCEL_FORCE_NO_BUILD_CACHE=1 in your project's environment variables.

igloo1505 commented 2 months ago

I was hopeful because it took quite a while, almost 9 minutes to build after getting stuck in the deploying outputs stage for a while, but I'm getting the Error: No more than 12 Serverless Functions can be added to a Deployment on the Hobby plan. Create a team (Pro plan) to deploy more. Learn More: https://vercel.link/function-count-limit error now after trying to build again both with and without the --env-mode=loose flag.

There are a reasonable number of routes and a TRPC route on the backend, but if I'm understanding correctly Next and Vercel bundle these routes together to address cold start issues?

Also, is it expected that api routes should show a size of 0? I have 2 utility routes and a trpc based route in the api folder, and they're all show a size of 0 bytes in the build output, along with the meta files, sitemap, manifest.webmanifest and robots.txt.