Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions packages/parity/src/engine/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1447,11 +1447,14 @@ export async function runSideBenchmark(opts: RunSideOptions): Promise<SideBenchm
id: `${opts.side}-${opts.viewport}-${id}`,
formFactor: ff,
});
const [home, plp, pdp] = await Promise.all([
lh("home", opts.base),
lh("plp", targets.category),
lh("pdp", targets.product),
]);
// Sequential, not Promise.all: Lighthouse measures CPU, so running the three
// pages at once both inflates their own numbers and starves Chrome's launch
// handshake while Playwright still holds browsers open — which fails all
// three attempts with "Unable to connect to Chrome". Same reasoning the
// vitals command encodes in its cores/2-capped-2 --lighthouse-concurrency.
const home = await lh("home", opts.base);
const plp = await lh("plp", targets.category);
const pdp = await lh("pdp", targets.product);
vitals = { home, plp, pdp };
}

Expand Down Expand Up @@ -1785,11 +1788,10 @@ export async function runSideBenchmarkContent(
id: `${opts.side}-${opts.viewport}-${id}`,
formFactor: ff,
});
const [home, plp, pdp] = await Promise.all([
lh("home", opts.base),
lh("page1", new URL(opts.contentPaths.pageA, opts.base).toString()),
lh("page2", new URL(opts.contentPaths.pageB, opts.base).toString()),
]);
// Sequential for the same reason as the commerce path above.
const home = await lh("home", opts.base);
const plp = await lh("page1", new URL(opts.contentPaths.pageA, opts.base).toString());
const pdp = await lh("page2", new URL(opts.contentPaths.pageB, opts.base).toString());
vitals = { home, plp, pdp };
}

Expand Down
9 changes: 7 additions & 2 deletions packages/parity/src/engine/lighthouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// run gets its own writable TEMP.
import { spawn } from "node:child_process";
import { mkdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
import { join, resolve } from "node:path";
import type { AgentA11yAudit, LhOpportunity, LhScores } from "../types/schema.ts";

export type { AgentA11yAudit, LhOpportunity, LhScores };
Expand Down Expand Up @@ -173,7 +173,12 @@ async function measureLighthouseOnce(
// dir and can hit EPERM there (Windows AV/ACL flakiness) — give this run its
// own writable TEMP so chrome-launcher's tmp dir creation lands somewhere
// uncontended instead of fighting --chrome-flags quoting.
const runTemp = join(opts.outDir, `.tmp-${opts.id}-a${attempt}`);
// MUST be absolute: this becomes TEMP/TMP for the spawned lighthouse, whose
// chrome-launcher feeds os.tmpdir() straight into Chrome's --user-data-dir.
// outDir descends from --output, which defaults to the RELATIVE "./parity-output",
// and Chrome cannot resolve a relative profile dir — it dies on launch and
// chrome-launcher reports the misleading "Unable to connect to Chrome".
const runTemp = resolve(opts.outDir, `.tmp-${opts.id}-a${attempt}`);
mkdirSync(runTemp, { recursive: true });
const args = [
"--yes",
Expand Down
Loading