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

Console class ignores ignoreErrors on Node.js v14.3.0 #33628

Closed
exoego opened this issue May 29, 2020 · 8 comments
Closed

Console class ignores ignoreErrors on Node.js v14.3.0 #33628

exoego opened this issue May 29, 2020 · 8 comments
Labels
stream Issues and PRs related to the stream subsystem.

Comments

@exoego
Copy link
Contributor

exoego commented May 29, 2020

What steps will reproduce the bug?

  1. Create a repro.js which contents is below:
ws = require('fs').createWriteStream('./foo.log');
ws.destroy();
c = new require('console').Console({
    stdout: ws,
    stderr: ws,
    ignoreErrors: false
});
c.log("should fail");
  1. Run ndoe repro.js

How often does it reproduce? Is there a required condition?

Every time it reproduces on the above environment with the above procedure.

What is the expected behavior?

Invoking c.log should throw error, since the underlying streams are already destroyed, like below:

events.js:287
      throw er; // Unhandled 'error' event
      ^

Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed

Note) The expected errors are thrown on Node.js v12.16.3 and v10.20.1.

What do you see instead?

No errors thrown, and script runs succesfully.
It seems that Console class ignores ignorErrors option.

@exoego exoego changed the title Console class do not respect ignoreErrors on Node.js Console class do not respect ignoreErrors on Node.js v14.3.0 May 29, 2020
@exoego exoego changed the title Console class do not respect ignoreErrors on Node.js v14.3.0 Console class ignores ignoreErrors on Node.js v14.3.0 May 29, 2020
@BridgeAR BridgeAR added the stream Issues and PRs related to the stream subsystem. label May 29, 2020
@BridgeAR
Copy link
Member

@ronag PTAL

@XadillaX
Copy link
Contributor

It seems because of

ws = require('fs').createWriteStream('./foo.log');
ws.destroy();
ws.write('foo');

do not throw error any more.

@ronag
Copy link
Member

ronag commented May 29, 2020

This is expected. You can't error an already destroyed stream. #29197

@exoego
Copy link
Contributor Author

exoego commented May 29, 2020

So, errors thrown on Node.js v12 & v10 were bug, that was fixed somewhere on v13/v14 ?

@XadillaX
Copy link
Contributor

But I think it's a breaking change.

@ronag
Copy link
Member

ronag commented May 29, 2020

But I think it's a breaking change.

Yes, it was labeled as semver-major.

@ronag
Copy link
Member

ronag commented May 29, 2020

So, errors thrown on Node.js v12 & v10 were bug, that was fixed somewhere on v13/v14 ?

Not sure exactly what you mean. A lot of things fall under that description. But this specific case wasn't a bug per se, but it was ambiguous/undefined behavior that we changed to make it predictable. There were also other problems this caused that the change resolved.

It was a very long discussion as you can notice from the PR and not at decision taken lightly.

@exoego
Copy link
Contributor Author

exoego commented May 29, 2020

Thanks for quick response 👍

I saw there was long disucssion in #29197, and the change seems reasonable to me.
My understanding is that the error I saw on Node.js v12 were due to ambiguous/undefined hehaviors.

I am closing this issue as "as-designed" or similar.

@exoego exoego closed this as completed May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants