GoogleChromeLabs / carlo

Web rendering surface for Node applications
Apache License 2.0
9.31k stars 309 forks source link

Sometimes carlo launches into the wrong window when using "--auto-open-devtools-for-tabs" launch arg #128

Open gadamsgh opened 5 years ago

gadamsgh commented 5 years ago

When debugging, it is useful to automatically launch devtools for the window, using the "--auto-open-devtools-for-tabs" flag.

Example main.js:

const carlo = require('carlo');

(async () => {
  const app = await carlo.launch({args:["--auto-open-devtools-for-tabs"]});
  app.on('exit', () => process.exit());
  app.serveFolder(__dirname);
  await app.load('https://www.google.com');
})();

Most of the time, google.com (site being launched in this case, happens with any site) will open in one window, and devtools will open in another window: image

Occasionally, both windows will initialize but google.com will open in the window intended for devtools (making the devtools inaccessible), leaving the window intended for google.com in an odd state. This occurs maybe 20% of the time on my Windows 10 machine.

image

pavelfeldman commented 5 years ago

Carlo assumes it manages windows and --auto-open-devtools-for-tabs breaks that assumption I guess...

lukehorvat commented 5 years ago

Yep, I've been encountering the same issue on Mac.

A crude workaround:

const app = await carlo.launch({ args: ['--auto-open-devtools-for-tabs'] });
app.on('exit', () => process.exit());
app.serveFolder(__dirname);

await app.createWindow(); // create a second window
await app.mainWindow().close(); // dispose the first window
await app.load('index.html');