console Chrome never outlives its run: exit kills it, SIGINT / SIGTERM / SIGHUP close it gracefully, a detached watchdog ends it when the parent dies (SIGKILL included; a reused pid is never killed); every start ends headless orphans on storebound profiles and names orphaned windows; headless runs on macOS prefer Chromium / Chrome for Testing over Google Chrome.app (an orphan kept the owner's Chrome from opening from the Dock); console fill closes the window on errors; pitfall 68; tests
This commit is contained in:
parent
b350781ab5
commit
89d94d6993
10 changed files with 372 additions and 17 deletions
|
|
@ -928,11 +928,9 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
...(args.get('cdp') ? { cdp: args.get('cdp') } : {}), ...(args.get('chrome-profile') ? { chromeProfile: args.get('chrome-profile') } : {}),
|
||||
useChromeSession: parseUseChromeSession(args.get('use-chrome-session') ?? (args.has('use-chrome-session') ? true : undefined)),
|
||||
});
|
||||
// Ctrl+C: close the browser gracefully (Chromium writes its cookies on a clean exit, so the sign-in is kept for the
|
||||
// next run), then remove the temporary profile of copy mode; that also happens on every other exit path
|
||||
let stopping = false;
|
||||
const bye = () => { if (stopping) return; stopping = true; void b.close().finally(() => { b.cleanup(); process.exit(130); }); };
|
||||
process.on('SIGINT', bye); process.on('SIGTERM', bye);
|
||||
// Ctrl+C / SIGTERM / SIGHUP close the browser gracefully (Chromium writes its cookies on a clean exit, so the sign-in
|
||||
// is kept for the next run) and remove the temporary profile of copy mode: cli/console/chrome-guard.ts. Every other
|
||||
// exit path (an error, a timeout) closes it in `finally`: a window left without its run becomes an orphan.
|
||||
try {
|
||||
// App Privacy opens by deep link when the app id is known (config, cache or the API by bundle id), else by the list
|
||||
const cfg = form === 'apple-app-privacy' && !startUrl ? withAppleAppId(config, await appleAppId(root, config, { say })) : config;
|
||||
|
|
@ -946,7 +944,10 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
if (out.debugDir) say(`debug dump: ${out.debugDir} (page.json, page.html, screen.jpg per step; no values, cookies or tokens; look at screen.jpg before you attach it to a bug report)`);
|
||||
if (out.timedOut) process.exitCode = 1;
|
||||
if (json) printJson({ ...res, ...out, stoppedAt: meta.stopBefore, browser: b.mode });
|
||||
} finally { b.cleanup(); process.off('SIGINT', bye); process.off('SIGTERM', bye); }
|
||||
} finally {
|
||||
if (!b.isClosed()) await b.close();
|
||||
b.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
export interface FillSessionOpts {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue