Skip to content

Occasional "No inspectable targets" error when launching chrome with a very short connectionPollInterval #145

Open
@robbertbrak

Description

@robbertbrak

To reproduce, create and run a Node script such as the one below:

const chromeLauncher = require('chrome-launcher');
const CDP = require('chrome-remote-interface');

let opts = {
  connectionPollInterval: 2,
  chromeFlags: ['--headless'],
};

(async() => {
  for (let i = 0; i < 100; i++) {
    let chrome = await chromeLauncher.launch(opts);
    let client = await CDP({port: chrome.port});
    console.log(i, chrome.port);
    client.close();
    chrome.kill();
  }
})().catch(error => { 
  console.log(error); 
  process.exit(1) 
});

After an unpredictable number of loops, the script (usually) crashes with a stacktrace:

Error: No inspectable targets
    at defaultTarget (.../node_modules/chrome-remote-interface/lib/chrome.js:47:23)
    at Chrome._fetchDebuggerURL (.../node_modules/chrome-remote-interface/lib/chrome.js:188:32)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

It looks like chrome-launcher occasionally reports that the launched Chrome instance is ready and has a debugging port, even though it isn't actually ready to accept a debug session yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions