Node: Cannot extend Console in node 10 rc.0

Created on 20 Apr 2018  路  5Comments  路  Source: nodejs/node

  • 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

console regression

Most helpful comment

Fix coming shortly.

All 5 comments

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:

https://github.com/nodejs/node/compare/a984551...2a6ab9b

I have a reproduction. Working on a fix.

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

Fix coming shortly.

Was this page helpful?
0 / 5 - 0 ratings