fix: wait for session switch settle in web probe

This commit is contained in:
Codex
2026-06-26 13:01:15 +00:00
parent b4370444b3
commit 8a15eef2c8
@@ -1746,14 +1746,21 @@ async function switchAwayAndBack(command) {
}
if (!alternateSessionId) throw new Error("switchAwayAndBack could not find an alternate session with strategy=" + strategy);
const switchAway = await clickSession(alternateSessionId);
const away = await workbenchSessionSnapshot();
const awaySettle = await waitForWorkbenchSessionHydrated(page, alternateSessionId, { timeoutMs: 15000 });
const away = awaySettle.snapshot ?? await workbenchSessionSnapshot();
const switchBack = await gotoTarget("/workbench/sessions/" + encodeURIComponent(canarySessionId));
const after = await workbenchSessionSnapshot();
const backSettle = await waitForWorkbenchSessionHydrated(page, canarySessionId, { timeoutMs: 15000 });
const after = backSettle.snapshot ?? await workbenchSessionSnapshot();
const routeOk = after?.routeSessionId === canarySessionId;
const activeOk = after?.activeSessionId === canarySessionId;
if (awaySettle.ok !== true) {
const error = new Error("switchAwayAndBack did not settle on the alternate session");
error.details = { canarySessionId, alternateSessionId, routeSessionId: away?.routeSessionId ?? null, activeSessionId: away?.activeSessionId ?? null, settle: awaySettle, pageId, valuesRedacted: true };
throw error;
}
if (!routeOk || !activeOk) {
const error = new Error("switchAwayAndBack did not return to the canary session");
error.details = { canarySessionId, alternateSessionId, routeSessionId: after?.routeSessionId ?? null, activeSessionId: after?.activeSessionId ?? null, pageId, valuesRedacted: true };
error.details = { canarySessionId, alternateSessionId, routeSessionId: after?.routeSessionId ?? null, activeSessionId: after?.activeSessionId ?? null, settle: backSettle, pageId, valuesRedacted: true };
throw error;
}
return {
@@ -1768,6 +1775,7 @@ async function switchAwayAndBack(command) {
beforeSessionCount: beforeSessionIds.length,
createResult: createResult === null ? null : { sessionId: alternateSessionId, valuesRedacted: true },
switchAway,
awaySettle,
away: {
routeSessionId: away?.routeSessionId ?? null,
activeSessionId: away?.activeSessionId ?? null,
@@ -1775,6 +1783,7 @@ async function switchAwayAndBack(command) {
valuesRedacted: true,
},
switchBack,
backSettle,
routeSessionId: after?.routeSessionId ?? null,
activeSessionId: after?.activeSessionId ?? null,
routeOk,