New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the ChromeLauncher API into a real thing. #2092
Comments
In! |
more on this: it's really handy to be able to run with maybe we should make a checklist of requirements :) |
That'd be great! The Calibre Chrome launcher is really similar to the Lighthouse one, with a couple of exceptions:
Another reason this might be great to have in a module is that downstream I'm very much in support of this. |
Seems useful. Mind putting together a requirements doc, more than happy to take care of this now that we have an idea about the use cases. |
usecaselaunch for Lighthouse or Headless (via cri) featuresfeature: port (auto-)selection:
feature: kill() method return and resolve
logisticskeep in repo, but publish as standalone module. API got sketched out more: https://public.etherpad-mozilla.org/p/chromelauncherapi const opts = {
chromeFlags: string, // e.g. '--show-paint-rects --disable-web-security'
port: number, // defaults to 0 aka auto, which finds an open port.
chromePath: string // we pick one automatically if you dont pass the filepath of the chrome/chromium binary
handleSIGINT: boolean // defaults totrue. iffalse we wouldn't bind to process.on("SIGINT")
};
const instance = await launcher.launch(opts);
// launch() resolves when chrome is launched and debugger protocol is ready
instance.port
instance.profilePath
instance.kill(); |
Some prior discussion: #1176 For now I'v stepped away from lighthouse as a means to launch Chrome. I've used it for a while but solved this problem better with my container orchestrator. Also I didn't like pulling in the whole lighthouse package, just for launching a process. One feature I'd liked to have seen was pluggable logging. |
The features described by @paulirish would be perfect for Speed Racer. I would clarify a multiple Chrome installation use case. In my use case I need to prioritize Canary for the headless support (I think that's what Lighthouse already does right?). But others might want to prioritize mainstream Chrome. I would prioritize Canary by default but let the user opt-out with something like this: const launcher = new ChromeLauncher({ canary: false }) |
I've been using lighthouse as a module and ham-fistedly added some of these (1, 2, 3, 4, 7 above) out of necessity to our very much in-development tool. I'd be happy to help with this, discuss our use cases, and/or add to the documentation @samccone @paulirish! |
This is now fixed. chrome-launcher is published on NPM and available: const chromeLauncher = require('chrome-launcher');
chromeLauncher.launch({
chromeFlags: ['--show-paint-rects']
}).then(chrome => {
console.log(`Chrome debugging port running on: ${chrome.port}`);
}); There is still some work remaining but please feel free to put it to use and report bugs. Thanks! |
Here's a few incarnations I'm seeing of people using the ChromeLauncher API:
and this dude who's just like "wtf is autoselect?": https://github.com/siddharthkp/lighthouse-ci/blob/c3938a2523434f26ea7963b0546fb241d4f21d36/index.js
(click above)
and not to mention the example in lighthouse's readme which is like whaaaaa..
There's a lot of variety and nothing I'm seeing in those snippets actually looks correct.
Feels like we could use chrome-launcher module that has a real first-class API.
Something with a very clear API surface to handle launch, getting the port number (if set with 0), ability to kill..
It'd also be nice to have sigint kill the process automatically as well. (our poor manual-chrome-launcher doesn't have this currently).
wdyt?
The text was updated successfully, but these errors were encountered: