Sitelet https://github.com/nodejs/node/issues/11805
Skip to content

console - writable property #11805

Description

@Wandalen

I am writing testing utilities and have trouble on nodejs platform ridding off unwanted output.
"console" is writable property in a browser. On nodejs "console's" methods could be rewritten iterating them, so making "console" non-writable does not give any insurance, but only make solving of my problem and similar more tedious. From my point of view having "console" non-writable counter-intuitive neither reasonable.

I propose to return writability to "console".

Activity

  1. added
    consoleIssues and PRs related to the console subsystem.
    on Mar 11, 2017
  2. sam-github commented on Mar 23, 2017

    @sam-github
    Contributor

    Sounds OK to me, @Wandalen, are you going to PR this?

  3. Wandalen commented on Mar 23, 2017

    @Wandalen
    ContributorAuthor

    OK fixing or OK leaving as is? :) I would be glad to make a pull request.

  4. addaleax commented on Mar 27, 2017

    @addaleax
    Member

    @Wandalen If you want, you can open a PR; the code you’ll want to look at is in setupGlobalConsole() in lib/internal/bootstrap_node.js.

    It’s not as simple as just switching a boolean, though; I think you might need to do something like addBuiltinLibsToObject() in lib/internal/module.js to work around the fact that we currently need a getter mechanism for global.console.

    I think it’s both ok to fix this and to leave it as is – the property is still configurable, so if you really want to, you can delete global.console; global.console = …; already.

    Let us know if you have any questions or there’s something we can help with!

  5. Wandalen commented on Mar 27, 2017

    @Wandalen
    ContributorAuthor

    Yes, sure, I will do. Thank you for hints, Addaleax.

  6. watilde commented on Mar 27, 2017

    @watilde
    Member
  7. Wandalen commented on Mar 27, 2017

    @Wandalen
    ContributorAuthor

    Understood, thank you. Will find free time soon.

  8. Wandalen commented on Apr 17, 2017

    @Wandalen
    ContributorAuthor

    Thank you @watilde for the link on w3c test and test from the repo, it was extremely useful. @addaleax you are right, overriding of a console with 2 steps( delete, assign ) was possible. Nevertheless, it was not consistent with the standard.

  9. Wandalen commented on Apr 17, 2017

    @Wandalen
    ContributorAuthor

    The first commit makes console overridable without delete with minimum changes.
    The second commit makes console writable, not enumerable and give property descriptor value field as it supposes to be according to the standard.
    One more test case stays commented out.
    A prototype of a console should have own none fields according to the standard, but currently, have:
    'constructor',
    'log',
    'info',
    'warn',
    'error',
    'dir',
    'time',
    'timeEnd',
    'trace',
    'assert'
    Please let me know should I make corresponding adjustments to make the test case pass.

  10. TimothyGu commented on Apr 17, 2017

    @TimothyGu
    Member

    A prototype of a console should have own none fields according to the standard

    That is true, but Node.js has always had console as an instance of require('console').Console, and it might be unfortunately too late to change that now due to backwards compatibility requirements.

  11. Wandalen commented on Apr 17, 2017

    @Wandalen
    ContributorAuthor

    @TimothyGu changes which you requested break test suite.

  12. Wandalen commented on Apr 17, 2017

    @Wandalen
    ContributorAuthor

    @TimothyGu thanks for your suggestions. Regarding the test case, I can try. Do you think that aspect of functionality covered by tests good enough to trust them? Currently, don't see why it would be impossible.

  13. TimothyGu commented on Apr 17, 2017

    @TimothyGu
    Member

    @Wandalen let's talk more about what you have included in the PR in the PR itself.

  14. Wandalen commented on Apr 22, 2017

    @Wandalen
    ContributorAuthor

    @TimothyGu, @watilde, @addaleax, @sam-github, @bnoordhuis, @Fishrock123 do you want any other adjustment? Can I be useful with other related issue?

  15. Trott commented on Aug 16, 2017

    @Trott
    Member

    I revived #12454 in the hopes of getting it landed (or, if there are firm objections to the whole concept, closed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    consoleIssues and PRs related to the console subsystem.feature requestIssues requesting new Node.js features.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions