From 91d96ba7e40b29f0bf374744f1fc38094a920bc1 Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Mon, 8 Jun 2026 08:20:10 -0700 Subject: [PATCH] test:perf: support authenticated boot runs via AC_SESSION_FILE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inject a logged-in session (localStorage @@auth0spajs@@ entries from a real signed-in browser, captured into a JSON file) before navigation, so the test can measure the authenticated boot path — where the historical ~8.7s userExists fetch lives. No creds in the repo; the session file is supplied out-of-band at run time. Anonymous path is the default when none is given. Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/performance/boot-performance.test.mjs | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/performance/boot-performance.test.mjs b/tests/performance/boot-performance.test.mjs index 76eb03494..3786bb424 100644 --- a/tests/performance/boot-performance.test.mjs +++ b/tests/performance/boot-performance.test.mjs @@ -15,7 +15,19 @@ // Single browser instance on purpose (8 GB machine — no parallel Chromium). import puppeteer from "puppeteer"; -import { writeFileSync, mkdirSync, existsSync } from "fs"; +import { writeFileSync, readFileSync, mkdirSync, existsSync } from "fs"; + +// Optional logged-in session: a JSON file of localStorage key→value pairs +// (the @@auth0spajs@@... entries from a real signed-in browser). When provided +// via AC_SESSION_FILE, we inject them before navigation so boot takes the +// authenticated path — that's where the historical ~8.7s userExists fetch hid. +// Capture from a logged-in tab's devtools console with: +// copy(JSON.stringify(Object.fromEntries(Object.entries(localStorage)))) +function loadSession() { + const f = process.env.AC_SESSION_FILE; + if (!f || !existsSync(f)) return null; + try { return JSON.parse(readFileSync(f, "utf8")); } catch { return null; } +} // Prefer a system Chrome (avoids puppeteer's version-pinned download). Override // with PUPPETEER_EXECUTABLE_PATH. Falls back to puppeteer's bundled binary. @@ -107,6 +119,17 @@ async function run() { try { const page = await browser.newPage(); await installBootProbe(page); + + const session = loadSession(); + if (session) { + await page.evaluateOnNewDocument((entries) => { + try { for (const [k, v] of Object.entries(entries)) localStorage.setItem(k, v); } catch {} + }, session); + console.log(` session: injecting ${Object.keys(session).length} localStorage keys (authenticated path)\n`); + } else { + console.log(` session: none — measuring the anonymous boot path\n`); + } + await page.coverage.startJSCoverage({ resetOnNavigation: false }); const wallStart = Date.now(); -- 2.51.2