Esm: Outputs by `console.log()` are not showing up in the Console panel of devtools

Created on 28 Jun 2018  路  3Comments  路  Source: standard-things/esm

Hi,

I found that outputs by console.log() are not showing up in the Console panel of the developer tools of Chrome.

For example, I have an index.js

global.originalConsole = console;
require('esm')(module)('./main');

which requires main.js

let i = 0;
setInterval(() => {
  i += 1;
  originalConsole.log('original console', i);
  console.log('esm console', i);
}, 1000);

I start with node --inspect=9229 index.js, which tells me Debugger listening on ws://127.0.0.1:9229/137fb2ca-8100-4eb1-9157-cf15ad15657b.

With that knowledge I visit chrome-devtools://devtools/bundled/inspector.html?ws=127.0.0.1:9229/137fb2ca-8100-4eb1-9157-cf15ad15657b

and find that in the Console panel, there is only "original console" lines, no "esm console" lines.

Here's the repro repo: esm-repro-issue-483

It's also possible to reproduce the problem using the debugging tools of VSCode with proper configurations.

I think it would better to take account of this scenario (debugging using dev tools) when replacing the original global console.

Thanks!

bug needs tests

All 3 comments

Thanks @Mensu!

This was a mis-detection on my part. I was detecting inspect flags without the = use.

@jdalton Just out of curiosity, but from here it seems that only ["debug", "dirxml", "info", "log"] methods will be associated with the original console.log, so it looks like outputs by other console methods (e.g. console.error, console.trace) would still not appear in the Console panel of the devtools...

https://github.com/standard-things/esm/blob/467f69f00c8b5243912ee5ddb3b09dde1b5f714c/src/builtin/console.js#L135-L145

Was this page helpful?
0 / 5 - 0 ratings