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.context() returns inert object #56634

Open
rotu opened this issue Jan 16, 2025 · 2 comments
Open

console.context() returns inert object #56634

rotu opened this issue Jan 16, 2025 · 2 comments

Comments

@rotu
Copy link

rotu commented Jan 16, 2025

Version

v22.13.0

Platform


Subsystem

No response

What steps will reproduce the bug?

let anon = console.context();
anon.log("I should be logged to console");

let named = console.context('name');
named.log("I should be logged to console too");

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

Every time you try to log anything via a context returned from console.context.

What is the expected behavior? Why is that the expected behavior?

The example should log the provided strings to console. This is the behavior in Chrome.

Otherwise, if Node does not intend to support these features, context() should not be exposed or should throw a runtime warning/error.

What do you see instead?

The above reproduction code does not log anything to the console, in the repl nor interactively.

Additional information

This (not well-documented) feature allows for multiple loggers to not conflict. E.g. calling console.group in one context does not affect the nesting level of another context. E.g. console.time in one context does not upset timers in another context.

It seems like the console.Console constructor is meant to work similarly.

@rotu rotu changed the title console.context doesn't work console.context() returns inert object Jan 16, 2025
@BridgeAR
Copy link
Member

BridgeAR commented Jan 17, 2025

There is no context method defined in the spec https://console.spec.whatwg.org. To achieve the separation, it's possible to create new console instances. Those have individual timers, grouping, etc.

@rotu
Copy link
Author

rotu commented Jan 17, 2025

There is no context method defined in the spec https://console.spec.whatwg.org.

Yes. It is non-spec (as is Error.stack!). It would be reasonable to either fix the V8 console.context() API or to remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants