这是indexloc提供的服务,不要输入任何密码
Skip to content

Specific package task definition causes nondeterministic behavior #905

@uhyo

Description

@uhyo

What version of Turborepo are you using?

1.1.6, 1.1.9, 1.2.0-canary.0

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

Yarn v1

What operating system are you using?

Mac

Describe the Bug

turbo run determines which tasks to run in a nondeterministic manner.

We have two packages a and b, and we have below turbo.json:

{
  "pipeline": {
    "generate": {},
    "build": {
      "dependsOn": [
        "generate"
      ]
    },
    "b#build": {}
  }
}

With this setting, turbo run build sometimes only run build script of a and sometimes runs both generate and build scripts of a.

We see two different results randomly:

yarn run v1.22.17
$ turbo run build
• Packages in scope: a, b
• Running build in 2 packages
a:build: cache hit, replaying output 967be7f13e8415ed
a:build: warning package.json: No license field
a:build: $ mkdir -p dist && echo built > ./dist/a.txt

 Tasks:    1 successful, 1 total
Cached:    1 cached, 1 total
  Time:    36ms >>> FULL TURBO

✨  Done in 0.15s.
yarn run v1.22.17
$ turbo run build
• Packages in scope: a, b
• Running build in 2 packages
a:generate: cache hit, replaying output 83eccbfec7d66441
a:generate: warning package.json: No license field
a:generate: $ mkdir -p generated && echo generated > ./generated/a.txt
a:build: cache hit, replaying output 967be7f13e8415ed
a:build: warning package.json: No license field
a:build: $ mkdir -p dist && echo built > ./dist/a.txt

 Tasks:    2 successful, 2 total
Cached:    2 cached, 2 total
  Time:    29ms >>> FULL TURBO

✨  Done in 0.16s.

Expected Behavior

Both generate and build scripts of a should be always run.

To Reproduce

Reproduction repo: https://github.com/uhyo/turborepo-nondeterministic

Clone the repo and run yarn install, and then run yarn repro many times.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions