Skip to content

vp run -r executes each package task twice when the root package has a matching recursive script #3221

Open

Description

@manai-lab

Summary

vp run -r <task> selects every package in the workspace including the workspace-root package. When the root package's package.json defines a same-named script that itself calls vp run -r <task> (the documented monorepo pattern), that script is expanded inline and schedules a second copy of every package's task in the same run — so each package's task runs twice concurrently.

Reproduction

// package.json (workspace root)
{
  "name": "workhub",
  "workspaces": { "packages": ["apps/*", "packages/*"] },
  "scripts": { "test": "vp run -r test" }
}
vp run -r test

Observed with vite-plus 1.2.0:

  • vp run summary reports ~2× the expected task count (e.g. 25 tasks for 12 packages).
  • vp run --last-details lists the same task id twice, e.g. @workhub/shared#test appears as two separate entries in one run.
  • Command echoes (~/packages/shared$ vp test run) and RUN v5.0.4 banners appear twice per package, started within ~2s of each other → the two executions run concurrently, not sequentially.

Why it is harmful

  • Doubled wall time for typecheck / lint / test on every vp run -r.
  • Any task that is not safe to run twice concurrently in the same directory breaks. Our apps/api story tests create a temporary probe file at a fixed path and lint it; the two concurrent vp test run processes raced on the filename (existsSync guard threw "already exists"), which is how we noticed — it failed our deploy pipeline.
  • --concurrency-limit does not help: both copies are in the same task graph.

Expected behavior

One of:

  1. -r does not select the workspace-root package's package.json scripts, or
  2. when a selected script expands to vp run invocations, the expanded task specs are deduplicated against already-scheduled tasks in the same run.

Workaround

Select packages explicitly, excluding root:

vp run -F './apps/*' -F './packages/*' test   # each package runs exactly once

Note -F and -r cannot be combined (--filter and --recursive cannot be used together), and {apps,packages}/* brace globs do not match — two -F flags are needed.

Environment

vite-plus 1.2.0, bun workspaces (apps/*, packages/*), Node 22, macOS arm64 and GitHub Actions ubuntu-latest (same behavior on both).

Activity

  1. added theissue type on Oct 24, 2026
  2. wan9chi commented on Oct 24, 2026

    @wan9chi
    Member

    Thanks for reporting! I can't seem to reproduce it based on your description. Could you please provide a minimal project that produces this issue?

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

Metadata

Metadata

Assignees

Type

Fields

Priority

None yet

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions