Flaky output from `--help`
Author: AndrewFinlayCreated Dec 31, 2019Updated Aug 2, 2026
Labelsbug
Hi all, it seems that when calling --help on a yargs project it can exit before all of the help content has been flushed to stdout.
I found this while trying to get nyc's test suite running consistently on my local machine, the nyc issue is here.
nyc has a test that compares the help output generated by yargs using nyc --help and a call to yargs.showHelp(). These generate the same output most of the time but the call to nyc --help may get truncated if the yargs call to process.exit(code) on line 978 of yargs.js is hit before the buffer has flushed.
According to the NodeJS docs the call to process.exit(code) can be heavy handed and exit before writes to stdout/stderr have completed.
Source: yargs/yargs