mirror of
https://github.com/webrecorder/browsertrix-crawler.git
synced 2025-10-19 14:33:17 +00:00
profiles: ensure all page.goto() promises have at least catch block or are awaited (#559)
In particular, an API call to /navigate starts, but doesn't wait for a page load to finish, since user can choose to close the profile browser at any time. This ensures that user operations don't cause the browser to crash if page.goto() is interrupted/fails (browser closed, profile is saved, etc...) while a page is still loading. bump to 1.1.1
This commit is contained in:
parent
15d2b09757
commit
a61206fd73
2 changed files with 19 additions and 4 deletions
|
@ -247,7 +247,11 @@ async function automatedProfile(
|
|||
|
||||
logger.info(`Loading page: ${params.url}`);
|
||||
|
||||
await page.goto(params.url, { waitUntil });
|
||||
try {
|
||||
await page.goto(params.url, { waitUntil });
|
||||
} catch (e) {
|
||||
logger.error("Page Load Failed/Interrupted", e);
|
||||
}
|
||||
|
||||
logger.debug("Looking for username and password entry fields on page...");
|
||||
|
||||
|
@ -404,9 +408,15 @@ class InteractiveBrowser {
|
|||
cdp.send("Page.enable");
|
||||
|
||||
cdp.on("Page.windowOpen", async (resp) => {
|
||||
if (resp.url) {
|
||||
if (!resp.url) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await cdp.send("Target.activateTarget", { targetId: this.targetId });
|
||||
await page.goto(resp.url);
|
||||
} catch (e) {
|
||||
logger.error("Page Load Failed/Interrupted", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -568,7 +578,12 @@ class InteractiveBrowser {
|
|||
res.writeHead(200, { "Content-Type": "application/json" });
|
||||
res.end(JSON.stringify({ success: true }));
|
||||
|
||||
this.page.goto(url);
|
||||
logger.info("Loading Page", { page: url });
|
||||
|
||||
this.page
|
||||
.goto(url)
|
||||
.catch((e) => logger.warn("Page Load Failed/Interrupted", e));
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (e: any) {
|
||||
res.writeHead(400, { "Content-Type": "application/json" });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue