fix(browser): skip CDP URL lookup for existing-session profiles
existing-session profiles set cdpUrl to '' (Chrome MCP auto-connect, no CDP port). Passing an empty cdpUrl to getPageForTargetId would always fail silently, leaving postRunUrl undefined and falling back to the stale pre-run tab.url. Explicitly skip the Playwright lookup when cdpUrl is empty and rely on tab.url, which the relay keeps updated via tabs.onUpdated.
This commit is contained in:
parent
696dcd5ddd
commit
8eac832ea9
@ -197,19 +197,26 @@ export async function withRouteTabContext<T>(
|
||||
// Note: cross-site navigations that trigger a renderer swap may
|
||||
// invalidate tab.targetId; in that case getPageForTargetId returns
|
||||
// null and we fall back to the (possibly stale) tab.url.
|
||||
try {
|
||||
const pwMod = await getPwAiModuleBase({ mode: "soft" });
|
||||
if (pwMod?.getPageForTargetId) {
|
||||
const page = await pwMod.getPageForTargetId({
|
||||
cdpUrl: profileCtx.profile.cdpUrl,
|
||||
targetId: tab.targetId,
|
||||
});
|
||||
if (page) {
|
||||
postRunUrl = page.url();
|
||||
// existing-session profiles set cdpUrl to "" (Chrome MCP auto-connect,
|
||||
// no CDP port). Passing an empty cdpUrl to getPageForTargetId would
|
||||
// always fail, so skip the Playwright lookup for those profiles and
|
||||
// rely on tab.url (updated by the relay on each tabs.onUpdated event).
|
||||
const cdpUrl = profileCtx.profile.cdpUrl;
|
||||
if (cdpUrl) {
|
||||
try {
|
||||
const pwMod = await getPwAiModuleBase({ mode: "soft" });
|
||||
if (pwMod?.getPageForTargetId) {
|
||||
const page = await pwMod.getPageForTargetId({
|
||||
cdpUrl,
|
||||
targetId: tab.targetId,
|
||||
});
|
||||
if (page) {
|
||||
postRunUrl = page.url();
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Playwright unavailable — fall back to tab.url
|
||||
}
|
||||
} catch {
|
||||
// Playwright unavailable — fall back to tab.url
|
||||
}
|
||||
}
|
||||
enrichTabResponseBody(interceptedBody, tab, postRunUrl);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user