Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typedoc is writing 1 byte to STDERR when successful, causing other tools to raise flags #1566

Closed
kaiyoma opened this issue Apr 9, 2021 · 4 comments
Labels
bug Functionality does not match expectation

Comments

@kaiyoma
Copy link

kaiyoma commented Apr 9, 2021

Expected Behavior

typedoc should not be writing anything to STDERR if it was successful.

Actual Behavior

typedoc writes a single byte (a newline, I think) to STDERR on success. This is problematic because other tools (like Rush.js, for instance, which I'm using) interpret STDERR content to mean that something failed. When I run typedoc through Rush, I get messages like this:

==[ SUCCESS WITH WARNINGS: 1 project ]=========================================

--[ WARNING: babel-plugin-generate-i18n-id ]----------------[ 10.85 seconds ]--

Projects succeeded with warnings.

Steps to reproduce the bug

You can see here pretty clearly that there's one byte of content in STDERR, even though the build was successful:

$ yarn typedoc > typedoc.stdout 2> typedoc.stderr

$ ls -l typedoc.std*
-rw-r--r-- 1 Kyle Getz 197121   1 Apr  9 11:09 typedoc.stderr
-rw-r--r-- 1 Kyle Getz 197121 234 Apr  9 11:09 typedoc.stdout

$ cat typedoc.stdout
yarn run v1.22.5
$ C:\Work\web-components\packages\babel-plugin-generate-i18n-id\node_modules\.bin\typedoc
Info: Documentation generated at C:\Work\web-components\packages\babel-plugin-generate-i18n-id\docs
Done in 10.96s.

(I tested this same sequence of commands with a non-typedoc tool and the STDERR file was 0 bytes, as expected.)

Environment

  • Typedoc version: 0.20.32
  • TypeScript version: 4.2.3
  • Node.js version: 14.15.0
  • OS: Windows 10
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 9, 2021

This is a weird one... and one I can't seem to reproduce. The only log statements in typedoc are in the bin file, and the ConsoleLogger. The ConsoleLogger always writes to stdout, since that's what TS does, and there are only 5 logs in the bin folder, 2 of which write to stderr... and that will only happen if there is an uncaught exception.

typedoc/bin/typedoc

Lines 29 to 30 in 2103f34

console.error("TypeDoc exiting with unexpected error:");
console.error(error);

ts.sys.write(output + ts.sys.newLine);

If you could set up a project that I could install that repros this issue, that would be great. My local test project doesn't seem to have this issue.

@Gerrit0 Gerrit0 added the needs reproduction Needs a minimal reproducible case label Apr 9, 2021
@kaiyoma
Copy link
Author

kaiyoma commented Apr 12, 2021

Here's a pretty small repro: typedoc-repro.zip

After you unzip, run these commands from the root:

rush install
cd packages/foo/
yarn typedoc > typedoc.stdout 2> typedoc.stderr
ls -l typedoc.std*

And you'll see the one byte coming from STDERR.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 23, 2021

So... turns out this isn't in TypeDoc. It's in the progress module, that we use for a progress bar... and it only shows up if you redirect stdout!

I think you win for the weirdest bug I've fixed this year so far...

@Gerrit0 Gerrit0 removed the needs reproduction Needs a minimal reproducible case label Apr 23, 2021
@kaiyoma
Copy link
Author

kaiyoma commented Apr 23, 2021

Lol excellent. 😄 Glad you were able to track it down! Weird indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants