Skip to content

fix(build): allow parallel builds into different outDirs - #24238

Open
mufasil wants to merge 1 commit into
vitejs:mainfrom
mufasil:fix/build-lock-outdir
Open

mufasil wants to merge 1 commit into
vitejs:mainfrom
mufasil:fix/build-lock-outdir

Conversation

@mufasil

@mufasil mufasil commented Nov 27, 2026

Copy link
Copy Markdown

This lets client and SSR builds run at the same time again when they write to different output directories. Builds targeting the same directory still use the existing lock protection.

The bug

The command lock added in 8.4.0 (#23624) treats a client build and an SSR build of the same app as duplicates. It checks the command, project root, config file, and mode, but not where the build writes its output.

That breaks a setup like this, even though the two builds write to separate folders:

{
  "scripts": {
    "build:client": "vite build --outDir dist/client",
    "build:server": "vite build --ssr src/entry-server.js --outDir dist/server",
    "build": "run-p build:client build:server"
  }
}

One of the builds exits with:

Error: Found another Vite build process for this project (PID 418141).
Pass --bypass-lock to bypass this check.
ERROR: "build:server" exited with 1.

Running client and server builds together is a common SSR setup, whether through run-p, concurrently, or turbo. On a fresh React SSR app, 8 of 10 runs failed with 8.4.0. The same setup passed all 10 runs with 8.3.8.

The failure depends on timing. Both processes can check for a lock before either writes one, so some runs still pass. That makes the problem harder to pin down in CI. --bypass-lock works around it, but this setup didn't need a bypass before 8.4.0.

The fix

Build lock records now include the resolved build.outDir. The existing checks still apply, but builds with different output directories no longer count as duplicates. The client and SSR builds above can run together without a bypass flag.

Builds targeting the same output directory are still blocked, since they could overwrite each other's files. Dev and preview locks are unchanged.

Older lock files from 8.4.0 don't have an outDir. Those still count as a match when the existing fields match, keeping the previous behavior for those records.

Tests

Added three tests in commandLock.spec.ts to check that the build record stores the resolved outDir, a build targeting a different directory is allowed, and a build targeting the same directory is blocked. Two of these tests fail without the fix and pass with it.

All 15 lock tests and 1,254 node unit tests pass. tsc, oxlint, and oxfmt are clean.

Manual checks with the built package on the same React SSR app passed all 10 parallel runs, and the SSR output renders. Two identical vite build commands running in parallel were still blocked in all 5 checks.

AI disclosure: I used Claude (an AI coding assistant) to help find the bug and write the fix and tests. The reproduction and checks above were run against the real npm packages and the built package.

The build lock treated a client build and an SSR build of the same
project as duplicates, so running them in parallel failed with
"Found another Vite build process". Store the resolved outDir for
builds and only treat builds into the same directory as duplicates.
@github-actions github-actions Bot added the bot: maybe Maybe a bot, LLM, or agent label Nov 27, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: maybe Maybe a bot, LLM, or agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant