Skip to content

Commit

Permalink
Fail the navigate just by main request failure
Browse files Browse the repository at this point in the history
  • Loading branch information
yeganemehr committed Apr 19, 2024
1 parent a1370ba commit 17b2f83
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/utils/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ class BroswerWrapper {
private goto(page: Page, options:IScreenshotOptions): Promise<void> {
return new Promise((resolve, reject) => {
page.on("requestfailed", (request) => {
console.log(request);
const url = request.url();
const failure = request.failure();
reject(new NavigationError(failure?.errorText || "UNKNOWN_ERROR", url));
if (url === options.url) {
const failure = request.failure();
reject(new NavigationError(failure?.errorText || "UNKNOWN_ERROR", url));
}
});
page.goto(options.url, { waitUntil: "networkidle2", timeout: options.timeout }).then(() => resolve(), reject);
})
Expand Down

0 comments on commit 17b2f83

Please sign in to comment.