fix: wait for monitor web readiness in screenshots

This commit is contained in:
Codex
2026-06-27 06:45:30 +00:00
parent f5a971b3d7
commit f84eb5f72a
2 changed files with 7 additions and 7 deletions
+4 -4
View File
@@ -1979,7 +1979,7 @@ for (let attempt = 1; attempt <= maxNavigationAttempts; attempt += 1) {
try {
const response = await page.goto(url, { timeout: perAttemptTimeout, waitUntil: "domcontentloaded" });
httpStatus = response?.status() ?? null;
await page.waitForLoadState("networkidle", { timeout: Math.min(5000, perAttemptTimeout) }).catch(() => {});
await page.waitForLoadState("networkidle", { timeout: Math.min(10000, perAttemptTimeout) }).catch(() => {});
await page.waitForFunction(() => {
const root = document.querySelector("#monitor-web-root");
if (!root) return false;
@@ -1988,10 +1988,10 @@ for (let attempt = 1; attempt <= maxNavigationAttempts; attempt += 1) {
const runs = document.querySelectorAll(".run-list .run-row").length;
const trend = document.querySelector("[data-monitor-trend-curve]");
return ready && (error || runs > 0 || trend);
}, null, { timeout: Math.min(5000, perAttemptTimeout) }).catch(() => {});
}, null, { timeout: Math.min(15000, perAttemptTimeout) }).catch(() => {});
await page.waitForTimeout(500);
const shellReady = await page.evaluate(() => Boolean(document.querySelector("#monitor-web-root"))).catch(() => false);
if (shellReady || attempt === maxNavigationAttempts) break;
const appReady = await page.evaluate(() => document.querySelector("#monitor-web-root")?.getAttribute("data-monitor-ready") === "true").catch(() => false);
if (appReady || attempt === maxNavigationAttempts) break;
} catch (error) {
navigationError = String(error?.message || error).slice(0, 500);
if (attempt === maxNavigationAttempts) break;