Skip to content

turbo test inputs have the same out-of-package hole #3514 closed for type-check — the root vitest.config.mts every package re-exports is not hashed #4178

Description

@yinlianghui

Found while implementing #3514 (PR #4176). Filed unassigned; not fixed there because that card is scoped to the type-check task.

The gap

#3514 established the mechanism: turbo hashes a task from its inputs, $TURBO_DEFAULT$ covers only files inside the package directory, and globalDependencies is unset — so any file a task reads from elsewhere in the repo is invisible to the cache key, and turbo replays the previous verdict instead of re-running. CI persists .turbo/cache through actions/cache, so the stale result travels.

The test task has exactly that shape, and every entry in its list is package-relative:

"inputs": [
  "src/**", "test/**", "tests/**",
  "vitest.config.*", "vitest.setup.*",
  "tsconfig*.json", "package.json",
  "$TURBO_DEFAULT$", "!**/*.md", "!**/CHANGELOG.md"
]

vitest.config.* and vitest.setup.* look like they cover the Vitest configuration, but they resolve inside the package. The files that actually decide how a package's tests run live at the repo root, and every package reaches them:

$ cat packages/core/vitest.config.ts
import rootConfig from '../../vitest.config.mts';
export default rootConfig;

The root vitest.config.mts owns the unit / dom / dom-heavy project split, sharedExclude, the domTsTests and heavyDomTests lists, and the alias table. The four root vitest.setup.* files decide which package graphs are registered before a test renders. None of them is hashed by any package's test task.

Measured

On claude/issue-3514-turbo-inputs-guard, @object-ui/core:

$ npx turbo run test --filter @object-ui/core --dry=json
  baseline                                    2e2087e2c30ef125
  after touching root vitest.config.mts       2e2087e2c30ef125     <- frozen
  after touching root vitest.setup.base.ts    2e2087e2c30ef125     <- frozen

The cache key does not move. The equivalent measurement on type-check before #4176 produced a FULL TURBO replay in 44ms over a real TS2688, with --force on the same tree exiting 2 — so this is the same defect, not a theoretical one.

Arguably worse than the type-check instance: a package's type-check reaches out only where a tsconfig says so, whereas every package's test run goes through the root Vitest config by construction.

Suggested shape

Symmetric with what #4176 landed, plus the guard question:

  1. Add the root files to the test task's inputs ($TURBO_ROOT$/vitest.config.mts, $TURBO_ROOT$/vitest.setup.*).
  2. scripts/__tests__/turbo-type-check-inputs.test.ts (from ci(turbo): derive the type-check inputs guard from each package's tsc program (#3514) #4176) is already written against a single TASK constant and derives out-of-package files from tsconfig programs. The test task's equivalent derivation is different in kind — it would have to follow the vitest.config.ts re-export chain rather than tsconfig include — so whether that is worth deriving or is better served by pinned pairs is a separate judgement, not a copy of guard: turbo type-check 的手维护 inputs 名单已两次因"包程序越出包目录"失真 —— 评估从 tsconfig include 派生或加钉扎测试 #3514's answer.

Whether the fix is the one-liner alone or the one-liner plus a guard is a maintainer/PM call, the same way #3514's was.

Related


Generated by Claude Code

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions