berry: [Bug]: `yarn workspaces foreach` always exits with status 0 even on error

Self-service

  • I’d be willing to implement a fix

Describe the bug

In Yarn@3.0.1, when I run a command with yarn workspaces foreach, it still return as successful even when a workspace process failed.

To reproduce

This is my repro: https://github.com/akphi/issue-repo/pull/1

I setup a test monorepo with 2 workspaces pkg1 and pkg2. Each workspace has a script called doSomething. pkg1 will exit with code 1 since the command error is not known.

At the root directory, if we run the following command, we got some unexpected result:

yarn workspaces foreach run doSomething                                          # no error
yarn workspaces foreach --all run doSomething                                    # no error
yarn workspaces foreach --parallel run doSomething                               # no error
yarn workspaces foreach --all --parallel --topological-dev run doSomething       # error

Environment

System: OS: macOS 11.5.1 CPU: (8) x64 Intel® Core™ i7-4870HQ CPU @ 2.50GHz Binaries: Node: 14.17.1 - /private/var/folders/95/y32364512q77c1dvhkpnr_n80000gn/T/xfs-02ae3755/node Yarn: 3.0.1 - /private/var/folders/95/y32364512q77c1dvhkpnr_n80000gn/T/xfs-02ae3755/yarn npm: 6.14.13 - ~/.nvm/versions/node/v14.17.1/bin/npm npmPackages: jest: 27.0.6 => 27.0.6

Additional context

Related to https://github.com/yarnpkg/berry/issues/2486

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 16

Most upvoted comments

Hey @akphi, no worries, that’s why we’re here, glad I could help!

What do you mean by "the failing script swallowed the error`?

Sorry, that was related to a problem in a personal project and why I investigated this issue in the first place. But based on my personal repository and the sherlock tests, this issue seems not reproducible anymore on the newest version (>= 3.2.0). Can you still reproduce it?