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

Cannot extend Console in node 10 rc.0 #20157

Closed
SimenB opened this issue Apr 19, 2018 · 5 comments
Closed

Cannot extend Console in node 10 rc.0 #20157

SimenB opened this issue Apr 19, 2018 · 5 comments
Labels
console Issues and PRs related to the console subsystem. regression Issues related to regressions.
Milestone

Comments

@SimenB
Copy link
Member

SimenB commented Apr 19, 2018

  • Version:
    10.0.0-rc.0
  • Platform:
    macOS
  • Subsystem:
    console

See the following file:

const {Console} = require('console');

class MyConsole extends Console {
  hello() {}
}

const cons = new MyConsole(process.stdout);

console.log(cons.hello)

This will log [Function: hello] in node 8 and node 9, but undefined in the RC.

I'm not sure if it's supposed to happen - my only guess from looking at the changelog is #17708, but I'm not sure if it's it?

This completely breaks Jest (which I wanted to test using the RC) as it extends Console for its own logging. See https://github.com/facebook/jest/blob/ef8f9ce4e02397dc75bdd510079bbfb36ad06728/packages/jest-util/src/buffered_console.js#L164-L166 which is undefined, meaning Jest errors out on an internal error here: https://github.com/facebook/jest/blob/ef8f9ce4e02397dc75bdd510079bbfb36ad06728/packages/jest-runner/src/run_test.js#L137

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Apr 19, 2018

I cannot reproduce with v10.0.0-nightly201804120aab8ff602 but can reproduce with the next v10.0.0-nightly201804132a6ab9b37b. So if I compare properly, the cause should be here:

a984551...2a6ab9b

@apapirovski
Copy link
Member

I have a reproduction. Working on a fix.

@vsemozhetbyt
Copy link
Contributor

cc @jasnell Sorry, seems like one more regression blocking v10.

@vsemozhetbyt vsemozhetbyt added this to the 10.0.0 milestone Apr 19, 2018
@vsemozhetbyt vsemozhetbyt added console Issues and PRs related to the console subsystem. regression Issues related to regressions. labels Apr 19, 2018
@apapirovski
Copy link
Member

Fix coming shortly.

@apapirovski
Copy link
Member

PR in #20158

jasnell pushed a commit that referenced this issue Apr 20, 2018
Due to a return statement with new inside the function, extending
Console class does not work when passing in just the stdout arg.

PR-URL: #20158
Fixes: #20157
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
console Issues and PRs related to the console subsystem. regression Issues related to regressions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants