You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
rotu
changed the title
console.context doesn't work
console.context() returns inert object
Jan 16, 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.
Version
v22.13.0
Platform
Subsystem
No response
What steps will reproduce the bug?
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.The text was updated successfully, but these errors were encountered: