Skip to content

Commit 754013c

Browse files
committed
Memory optimization in cases where the navigation fails
1 parent 65cdac7 commit 754013c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

index.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,18 @@ const iPadPro = devices['iPad Pro landscape'];
4545

4646
// Navigate to page
4747
utils.log('Loading page...')
48-
await page.goto(argv.url, { timeout: 120000 })
48+
let errors = []
49+
await page.goto(argv.url, { timeout: 120000 }).catch(async e => {
50+
errors.push(e)
51+
utils.log(`Error: Couldn't navigate to ${argv.url}`)
52+
})
53+
54+
// If errors happened then we'll need to terminate
55+
if (errors.length > 0) {
56+
await page.close()
57+
await browser.close()
58+
return 'navigationError'
59+
}
4960

5061
// Wait for given amount in ms
5162
if (argv.wait) {
@@ -57,8 +68,9 @@ const iPadPro = devices['iPad Pro landscape'];
5768
const finalUrl = await page.url()
5869
utils.log(`URL given as a parameter: ${argv.url} Document downloaded from URL: ${finalUrl}`)
5970

60-
// Close the page
71+
// Close the page & browser
6172
utils.log('Closing the page...')
73+
await page.close()
6274
await browser.close()
6375

6476
// Figure out the compare to origins

0 commit comments

Comments
 (0)