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

test,console: add testing for monkeypatching of console stdio #26561

Closed
wants to merge 1 commit into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Mar 10, 2019

lib/internal/console/constructor.js contains setters for console._stdout
and console._stderr but these setters are not used in our tests or in
Node.js core. (This is confirmed by our nightly coverage reports.)

Add a test to check monkeypatching _stdout and _stderr on a console
object.

Version 2.6.9 of the very-popular npm module debug used this
monkeypatching in its code. No other version did and they are now at
version 4.something. It is not inconceivable that we would want to
change the setters to throw rather than work. Given that this has seen
use in the ecosystem, I'm inclined to leave the functionality in place.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

lib/internal/console/constructor.js contains setters for console._stdout
and console._stderr but these setters are not used in our tests or in
Node.js core. (This is confirmed by our nightly coverage reports.)

Add a test to check monkeypatching _stdout and _stderr on a console
object.

Version 2.6.9 of the very-popular npm module `debug` used this
monkeypatching in its code. No other version did and they are now at
version 4.something. It is not inconceivable that we would want to
change the setters to throw rather than work. Given that this has seen
use in the ecosystem, I'm inclined to leave the functionality in place.
@Trott Trott added test Issues and PRs related to the tests. console Issues and PRs related to the console subsystem. labels Mar 10, 2019
@Trott
Copy link
Member Author

Trott commented Mar 10, 2019

@BridgeAR
Copy link
Member

The part where debug uses it seems to be a internal debugging functionality? Since it was added in the release commit I expect it to be added by accident by using e.g. git commit add ..

A user of debug v2.6.9 would not trigger this part.

I would therefore go ahead and deprecate or remove the setter (the latter only with a clean CITGM run and no entries with https://github.com/nodejs/Gzemnid).

@Trott
Copy link
Member Author

Trott commented Mar 10, 2019

The part where debug uses it seems to be a internal debugging functionality?

That might still be an argument for keeping it. Someone, at one point, found monkey-patching it useful.

My opinion on this isn't a strong one, though, and I'd be fine with checking Gzemnid, changing the setter so that it throws, and running CITGM as an alternative. I worry that would stall, though, so I'd prefer to leave this open (and even land it) while that other process proceeds.

@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 12, 2019
Trott added a commit to Trott/io.js that referenced this pull request Mar 17, 2019
lib/internal/console/constructor.js contains setters for console._stdout
and console._stderr but these setters are not used in our tests or in
Node.js core. (This is confirmed by our nightly coverage reports.)

Add a test to check monkeypatching _stdout and _stderr on a console
object.

PR-URL: nodejs#26561
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@Trott
Copy link
Member Author

Trott commented Mar 17, 2019

Landed in 6913bd1 so we have a test for the setters. Will open a semver-major to change this behavior and we'll see how that goes.

@Trott Trott closed this Mar 17, 2019
@Trott
Copy link
Member Author

Trott commented Mar 17, 2019

Will open a semver-major to change this behavior and we'll see how that goes.

Actually, I think I'm not going to do that. We don't seem to prevent this sort of thing generally and there's no existing error code that I can find that seems to fit, suggesting we may not really do this at all? I'm not opposed to doing it, but it seems like a potentially significant departure and I'm inclined to leave well-enough alone.

targos pushed a commit to targos/node that referenced this pull request Mar 27, 2019
lib/internal/console/constructor.js contains setters for console._stdout
and console._stderr but these setters are not used in our tests or in
Node.js core. (This is confirmed by our nightly coverage reports.)

Add a test to check monkeypatching _stdout and _stderr on a console
object.

PR-URL: nodejs#26561
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
targos pushed a commit that referenced this pull request Mar 27, 2019
lib/internal/console/constructor.js contains setters for console._stdout
and console._stderr but these setters are not used in our tests or in
Node.js core. (This is confirmed by our nightly coverage reports.)

Add a test to check monkeypatching _stdout and _stderr on a console
object.

PR-URL: #26561
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
BethGriggs pushed a commit that referenced this pull request Apr 17, 2019
lib/internal/console/constructor.js contains setters for console._stdout
and console._stderr but these setters are not used in our tests or in
Node.js core. (This is confirmed by our nightly coverage reports.)

Add a test to check monkeypatching _stdout and _stderr on a console
object.

PR-URL: #26561
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@BethGriggs BethGriggs mentioned this pull request May 1, 2019
@Trott Trott deleted the test-console-setters branch January 13, 2022 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. console Issues and PRs related to the console subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants