Skip to content

Fix: Skip Non-HTTP Protocol in New Tab Handling to Prevent Errors #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
31 changes: 17 additions & 14 deletions lib/handlers/actHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,21 +525,24 @@ export class StagehandActHandler {
});

if (newOpenedTab) {
this.logger({
category: "action",
message: "new page detected (new tab) with URL",
level: 1,
auxiliary: {
url: {
value: newOpenedTab.url(),
type: "string",
const newOpenedTabUrl = newOpenedTab.url();
if (newOpenedTabUrl.startsWith("http")) {
this.logger({
category: "action",
message: "new page detected (new tab) with URL",
level: 1,
auxiliary: {
url: {
value: newOpenedTabUrl,
type: "string",
},
},
},
});
await newOpenedTab.close();
await this.stagehandPage.page.goto(newOpenedTab.url());
await this.stagehandPage.page.waitForLoadState("domcontentloaded");
await this.stagehandPage._waitForSettledDom(domSettleTimeoutMs);
});
await newOpenedTab.close();
await this.stagehandPage.page.goto(newOpenedTabUrl);
await this.stagehandPage.page.waitForLoadState("domcontentloaded");
await this.stagehandPage._waitForSettledDom(domSettleTimeoutMs);
}
}

await Promise.race([
Expand Down