actions / actions/toolkit

stderr is always sent to stdout unless failOnStdErr is true

Open
#1,568 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
A processes stderr is always sent to stdout instead of stderr unless the failOnStdErr option is set.

I want to silence stdout while keeping stderr. I tried to do this with this line:

const output = await getExecOutput('my-command', ['my-args'], {
  outStream: nullStream,
  errStream: process.stderr, // alternatively without this line
})

however, this unexpectedly silences both stdout and stderr.
Also setting the failOnStdErr option to true fixes the above problem, but also throws an error if the command prints to stderr, even when returning with a 0 exit code.

To Reproduce
Steps to reproduce the behavior:

  1. Run this in a GitHub Action:
const nullStream = new stream.Writable({
  write(chunk: never, encoding: never, callback: never) {}
})

await exec('bash', ['-c', 'echo test 1>&2'], {
  outStream: nullStream,
})
  1. Observe stdout and stderr

Expected behavior
The program should output 'test' to stderr

Actual behavior
There is no output

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the getExecOutput and exec stream-handling entry points, then reproduce the issue with the provided bash command and custom nullStream. Done means stdout can be suppressed while stderr remains visible, without requiring failOnStdErr or throwing for a successful command that writes to stderr.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.