Lerna: stderr output is ignored if a `run` script does not fail

Created on 26 Jul 2019  路  3Comments  路  Source: lerna/lerna


Tasks that succeed or tasks that fail with --no-bail enabled simply discard stderr output. This output is important and discarding it can make figuring out what is happening in running tasks very difficult.

https://github.com/lerna/lerna/blob/master/commands/run/index.js#L167

Expected Behavior

stderr is reported for successful tasks.

Current Behavior

stderr is only logged if a task fails.

Possible Solution

Always log stderr in the above linked method.

Steps to Reproduce (for bugs)


  1. Create an npm script test that logs to stdout and stderr while returning a 0 exit code
  2. lerna run test
  3. Notice that stderr is not output

Your Environment

| Executable | Version |
| ---: | :--- |
| lerna --version | 3.15.0 |
| node --version | v10.13.0 |

Most helpful comment

The change in the linked PR is strictly to the batched mode. I agree it doesn't mean it's an error, but frequently it contains useful information (at least in my repo) and the lack of it makes it really hard to debug when I run scripts across my 50+ packages.

The biggest failure mode for me is when I want to run all of the tests in my repo and then review all the failures (common after a big framework change). Then I'll use lerna run test --no-bail so that I don't have to run lerna run test over and over again. However, all of the useful errors are sent to stderr, which is then dropped when --no-bail is present.

All 3 comments

Messages sent to stderr does not mean the process encountered an error. That's what process.exitCode/process.exit(code) is for.

Well-behaved CLI programs emit logging to stderr, which is generally extremely noisy and can become almost worthless in a parallel execution that lerna often creates.

If you _want_ this situation, it seems like you're really looking for --stream (add --concurrency 1 --no-prefix to reduce the interleaving, maybe).

The change in the linked PR is strictly to the batched mode. I agree it doesn't mean it's an error, but frequently it contains useful information (at least in my repo) and the lack of it makes it really hard to debug when I run scripts across my 50+ packages.

The biggest failure mode for me is when I want to run all of the tests in my repo and then review all the failures (common after a big framework change). Then I'll use lerna run test --no-bail so that I don't have to run lerna run test over and over again. However, all of the useful errors are sent to stderr, which is then dropped when --no-bail is present.

If I restricted my change to only log stderr when this.bail === false would that make you more comfortable with it?

Was this page helpful?
0 / 5 - 0 ratings