fix(ext/web): forward console.group label to inspector log#34341
Merged
Conversation
`console.group(label)` opens a startGroup event on the V8 inspector, but Chrome DevTools renders the group container with no visible label unless it also receives a paired `log` event carrying that label — which is what Node's console does. Deno's `group` previously called `this.log(label)`, but because the methods are arrow class fields the lexical `this` is the original Console instance, so `this.log` resolved to the *unwrapped* log and never reached the inspector. The result was a startGroup event with no following log, and DevTools displayed empty nested containers that visibly drifted out of alignment with the CLI output. Stash a reference to the namespace object returned from the constructor and route the label log through it, so when the inspector wraps console methods, `group` invokes the wrapped `log` that fans out to both the V8 console binding and the printer. Closes denoland/orchid#206 Co-Authored-By: Divy Srivastava <[email protected]>
The previous --inspect-brk pattern needed an extra Debugger.resume round-trip after Debugger.paused to actually run the script; without it, the script stayed paused on first line and never emitted the console events the test was waiting on. This race showed up as a 1m timeout on debug aarch64 runners. --inspect-wait pauses until Runtime.runIfWaitingForDebugger is called, which is what the test already sends — matching the pattern in inspector_wait. Co-Authored-By: Divy Srivastava <[email protected]>
littledivy
approved these changes
May 29, 2026
littledivy
added a commit
to crowlKats/deno
that referenced
this pull request
Jun 10, 2026
…34341) ## Summary `console.group(label)` opens a `startGroup` event on the V8 inspector, but Chrome DevTools renders the group container with no visible label unless it also receives a paired `log` event carrying that label — which is what Node's console does. Deno's `group` previously called `this.log(label)`, but because the methods are arrow class fields the lexical `this` is the original `Console` instance, so `this.log` resolved to the *unwrapped* `log` and never reached the inspector. The result was a `startGroup` event with no following `log`, and DevTools displayed empty nested containers that visibly drifted out of alignment with the CLI output. The fix stashes a reference to the namespace object returned from the constructor and routes the label log through it, so when the inspector wraps console methods, `group` invokes the *wrapped* `log` that fans out to both the V8 console binding and the printer. This matches Node — inspector captures for the issue's repro script now produce: ``` startGroup test1 / log test1 / startGroup test2 / log test2 / ... ``` instead of just: ``` startGroup test1 / startGroup test2 / ... ``` Closes denoland#30176. Closes denoland/orchid#206. Note: a prior attempt (denoland#32869) tried to *remove* the `this.log` call inside `group`, on the theory that the duplicate inspector event was the bug. That theory was inverted — `this.log` was already silently *not* hitting the inspector at all because of the arrow-function `this`, and DevTools was showing an empty group as a result. This PR makes `group` reliably reach the wrapped `log`, which is the inspector signal DevTools is looking for. ## Test plan - [x] New unit test `consoleGroupForwardsLabelToWrappedLog` in `tests/unit/console_test.ts` simulates the inspector wrap with a spy v8 console and asserts both `group` and `log` events fire with the label while the CLI indentation stays unchanged. - [x] New integration test `inspector_console_group_emits_label_log` in `tests/unit/inspector_test.ts` runs a real `--inspect-brk` session, drives the CDP socket, and asserts the `Runtime.consoleAPICalled` event stream has the matching `log`/`startGroup` pairs DevTools needs. - [x] All existing `console_test.ts` tests pass (87 passed, 0 failed) — CLI output of `console.group` and indentation are unchanged. --------- Co-authored-by: divybot <[email protected]> Co-authored-by: Divy Srivastava <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
console.group(label)opens astartGroupevent on the V8 inspector, butChrome DevTools renders the group container with no visible label unless it
also receives a paired
logevent carrying that label — which is what Node'sconsole does. Deno's
grouppreviously calledthis.log(label), but becausethe methods are arrow class fields the lexical
thisis the originalConsoleinstance, sothis.logresolved to the unwrappedlogand neverreached the inspector. The result was a
startGroupevent with no followinglog, and DevTools displayed empty nested containers that visibly driftedout of alignment with the CLI output.
The fix stashes a reference to the namespace object returned from the
constructor and routes the label log through it, so when the inspector wraps
console methods,
groupinvokes the wrappedlogthat fans out to boththe V8 console binding and the printer. This matches Node — inspector
captures for the issue's repro script now produce:
instead of just:
Closes #30176. Closes denoland/orchid#206.
Note: a prior attempt (#32869) tried to remove the
this.logcall insidegroup, on the theory that the duplicate inspector event was the bug. Thattheory was inverted —
this.logwas already silently not hitting theinspector at all because of the arrow-function
this, and DevTools wasshowing an empty group as a result. This PR makes
groupreliably reach thewrapped
log, which is the inspector signal DevTools is looking for.Test plan
consoleGroupForwardsLabelToWrappedLogintests/unit/console_test.tssimulates the inspector wrap with a spy v8console and asserts both
groupandlogevents fire with the labelwhile the CLI indentation stays unchanged.
inspector_console_group_emits_label_logintests/unit/inspector_test.tsruns a real--inspect-brksession, drivesthe CDP socket, and asserts the
Runtime.consoleAPICalledevent streamhas the matching
log/startGrouppairs DevTools needs.console_test.tstests pass (87 passed, 0 failed) — CLIoutput of
console.groupand indentation are unchanged.