browser: one launch resolver; console fill never reports a hidden error
`console fill --fresh-profile` failed with "Executable doesn't exist ... chromium-1187" when only Playwright's headless shell was downloaded, although Google Chrome was installed (also with STOREBOUND_CHROME set). The Chrome launch did run, but failed because an earlier storebound run still held the profile, and the fallback rethrew the FIRST error. Every launch (renders, captures, console profile and copy modes, the desktop sidecar) now goes through one resolver that checks the exact executable before trying it: - headless: STOREBOUND_CHROME, headless shell, full Chromium, Chrome - visible / persistent: STOREBOUND_CHROME, Google Chrome, full Chromium (channel "chromium"); never the headless shell - copy mode: Google Chrome only A missing browser is skipped; an installed one that fails reports its own error; nothing usable names what was looked for plus the doctor / playwright install hint. A profile whose SingletonLock names a live process is reported before launching.
This commit is contained in:
parent
ee99b99f8d
commit
0f21149aaf
3 changed files with 291 additions and 25 deletions
|
|
@ -28,7 +28,7 @@
|
|||
import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
||||
import { homedir, tmpdir } from 'node:os';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { chromiumFor, launchPersistent } from '../shots/browser';
|
||||
import { chromiumFor, type LaunchDeps, launchPersistent } from '../shots/browser';
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
|
|
@ -170,6 +170,8 @@ export interface OpenOpts {
|
|||
platform?: string;
|
||||
/** Tests: Playwright's launch timeout for modes (b) and (c) (default: Playwright's 30 s). */
|
||||
launchTimeoutMs?: number;
|
||||
/** Tests: Playwright's chromium and the installed browsers the launch resolver sees. */
|
||||
launchDeps?: LaunchDeps;
|
||||
say: (m: string) => void;
|
||||
}
|
||||
|
||||
|
|
@ -213,7 +215,7 @@ export async function openConsoleBrowser(root: string, o: OpenOpts): Promise<Con
|
|||
const endpoint = o.cdp ?? devToolsEndpoint(chromeDir);
|
||||
if (endpoint) {
|
||||
try {
|
||||
const c = await chromiumFor(root);
|
||||
const c = o.launchDeps?.pw ?? await chromiumFor(root);
|
||||
const browser = await c.connectOverCDP(endpoint, { timeout: 5000 });
|
||||
const context = browser.contexts()[0] ?? await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
|
|
@ -233,12 +235,11 @@ export async function openConsoleBrowser(root: string, o: OpenOpts): Promise<Con
|
|||
let copy: SessionCopy | null = null;
|
||||
try {
|
||||
copy = await copySession(chromeDir, { ...(o.chromeProfile ? { profile: o.chromeProfile } : {}), ...(o.hosts ? { hosts: o.hosts } : {}) });
|
||||
const c = await chromiumFor(root);
|
||||
const context = await c.launchPersistentContext(copy.dir, {
|
||||
channel: 'chrome', headless: o.headless ?? false, viewport: null, args: KEEP_SESSION_ARGS, ...(o.launchTimeoutMs ? { timeout: o.launchTimeoutMs } : {}),
|
||||
const context = await launchPersistent(root, copy.dir, {
|
||||
headless: o.headless ?? false, viewport: null, args: KEEP_SESSION_ARGS, ...(o.launchTimeoutMs ? { timeout: o.launchTimeoutMs } : {}),
|
||||
// Playwright's mock keychain would hide Chrome's own key, and the cookies could not be read
|
||||
ignoreDefaultArgs: ['--use-mock-keychain', '--password-store=basic'],
|
||||
});
|
||||
}, { ...o.launchDeps, kind: 'chrome' }); // only real Google Chrome decrypts the owner's cookies
|
||||
o.say(`browser: your Chrome sign-in (profile "${copy.profile}"). storebound copied only ${copy.files.join(', ')} into a temporary profile`
|
||||
+ `${copy.filtered ? `, kept only the cookies for App Store Connect and Play Console (${copy.kept ?? 0})` : ' (the whole cookie file: it could not be filtered)'}`
|
||||
+ ', and deletes it when this run ends. Passwords, history and extensions are never copied. macOS may ask once to let Google Chrome use "Chrome Safe Storage" in your Keychain: that is Chrome reading its own cookies. Opt out: --fresh-profile');
|
||||
|
|
@ -253,7 +254,7 @@ export async function openConsoleBrowser(root: string, o: OpenOpts): Promise<Con
|
|||
}
|
||||
// (c) storebound's persistent profile, the owner signs in there
|
||||
mkdirSync(o.profileDir, { recursive: true });
|
||||
const context = await launchPersistent(root, o.profileDir, { headless: o.headless ?? false, viewport: null, args: KEEP_SESSION_ARGS, ...(o.launchTimeoutMs ? { timeout: o.launchTimeoutMs } : {}) });
|
||||
const context = await launchPersistent(root, o.profileDir, { headless: o.headless ?? false, viewport: null, args: KEEP_SESSION_ARGS, ...(o.launchTimeoutMs ? { timeout: o.launchTimeoutMs } : {}) }, { ...o.launchDeps, kind: 'visible' });
|
||||
o.say(`browser: storebound's own profile (${o.profileDir}); sign in there once, it is kept for the next run`);
|
||||
const page = await ownTab(context);
|
||||
return wrapContext('profile', context, page, () => { /* kept on purpose */ });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue