nodejs / nodejs/node

console.group() emits duplicate CDP messages

Open
#31,973 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

console inspector
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

  • Version: v12.11.1
  • Platform: Darwin 10.14
What steps will reproduce the bug?

With a debugger attached, invoke:

console.group('group name', { foo: true });
How often does it reproduce? Is there a required condition?

Every time

What is the expected behavior?

There should be a single CDP message for the console group. Running that line of code in the Chrome devtools, that is the case and I get a single message:

image

What do you see instead?

Running that line of code in Node.js, I get two messages--the correct startGroup type, and then an additional log message whose stack says it comes from the group method in internal/console/constructor.js

{"method":"Runtime.consoleAPICalled","params":{"type":"startGroup","args":[{"type":"string","value":"group name"},{"type":"object","className":"Object","description":"Object","objectId":"{\"injectedScriptId\":1,\"id\":1}","preview":{"type":"object","description":"Object","overflow":false,"properties":[{"name":"foo","type":"boolean","value":"true"}]}}],"executionContextId":1,"timestamp":1582746620974.181,"stackTrace":{"callFrames":[{"functionName":"","scriptId":"97","url":"file:///Users/copeet/Github/vscode-pwa/demos/node/main.js","lineNumber":1,"columnNumber":8},{"functionName":"Module._compile","scriptId":"43","url":"internal/modules/cjs/loader.js","lineNumber":944,"columnNumber":29},{"functionName":"Module._extensions..js","scriptId":"43","url":"internal/modules/cjs/loader.js","lineNumber":961,"columnNumber":9},{"functionName":"Module.load","scriptId":"43","url":"internal/modules/cjs/loader.js","lineNumber":797,"columnNumber":31},{"functionName":"Module._load","scriptId":"43","url":"internal/modules/cjs/loader.js","lineNumber":710,"columnNumber":11},{"functionName":"Module.runMain","scriptId":"43","url":"internal/modules/cjs/loader.js","lineNumber":1013,"columnNumber":9},{"functionName":"","scriptId":"39","url":"internal/main/run_main_module.js","lineNumber":16,"columnNumber":10}]}}}
{"method":"Runtime.consoleAPICalled","params":{"type":"log","args":[{"type":"string","value":"group name"},{"type":"object","className":"Object","description":"Object","objectId":"{\"injectedScriptId\":1,\"id\":2}","preview":{"type":"object","description":"Object","overflow":false,"properties":[{"name":"foo","type":"boolean","value":"true"}]}}],"executionContextId":1,"timestamp":1582746620974.757,"stackTrace":{"callFrames":[{"functionName":"group","scriptId":"25","url":"internal/console/constructor.js","lineNumber":385,"columnNumber":11},{"functionName":"","scriptId":"97","url":"file:///Users/copeet/Github/vscode-pwa/demos/node/main.js","lineNumber":1,"columnNumber":8},{"functionName":"Module._compile","scriptId":"43","url":"internal/modules/cjs/loader.js","lineNumber":944,"columnNumber":29},{"functionName":"Module._extensions..js","scriptId":"43","url":"internal/modules/cjs/loader.js","lineNumber":961,"columnNumber":9},{"functionName":"Module.load","scriptId":"43","url":"internal/modules/cjs/loader.js","lineNumber":797,"columnNumber":31},{"functionName":"Module._load","scriptId":"43","url":"internal/modules/cjs/loader.js","lineNumber":710,"columnNumber":11},{"functionName":"Module.runMain","scriptId":"43","url":"internal/modules/cjs/loader.js","lineNumber":1013,"columnNumber":9},{"functionName":"","scriptId":"39","url":"internal/main/run_main_module.js","lineNumber":16,"columnNumber":10}]}}}
Additional information

For now I can look for this behavior inside our debugger and ignore logs that come from the 'group' function in that file, though this is rather delicate. It'd be nice to have it resolved 🙂

Ref: https://github.com/microsoft/vscode/issues/91095

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with console.group('group name', { foo: true }) while a debugger is attached, then inspect the group method in internal/console/constructor.js. Compare the emitted Runtime.consoleAPICalled messages with the expected single startGroup message. Done means the extra log message no longer appears while the group event and its arguments remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
backend, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
67/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.