From 8f1aafb10c3cf349874ce3dd4894b70c0712f605 Mon Sep 17 00:00:00 2001
From: Bart Veneman
Date: Thu, 25 Nov 2021 19:47:56 +0100
Subject: [PATCH] close browser onerror
---
api/_chromium.js | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/api/_chromium.js b/api/_chromium.js
index 9425ebe..fa4e967 100644
--- a/api/_chromium.js
+++ b/api/_chromium.js
@@ -25,6 +25,7 @@ export const extractCss = async url => {
// Make sure that we only try to extract CSS from valid pages.
// Bail out if the response is an invalid request (400, 500)
if (response.status() >= 400) {
+ await browser.close()
return Promise.reject(
new Error(
`There was an error retrieving CSS from ${url}.\n\tHTTP status code: ${response.statusCode} (${response.statusText})`
@@ -38,14 +39,13 @@ export const extractCss = async url => {
if (headers['content-type'].includes('text/css')) {
const css = await response.text()
+ await browser.close()
- return Promise.resolve([
- {
- type: 'file',
- href: url,
- css
- }
- ])
+ return Promise.resolve([{
+ type: 'file',
+ href: url,
+ css
+ }])
}
// Coverage contains a lot of and CSS,
@@ -105,9 +105,11 @@ export const extractCss = async url => {
type: 'link-or-import'
}))
- const css = links
+ const resources = links
.concat(styleSheetsApiCss)
.concat(inlineCss)
- return Promise.resolve(css)
+ await browser.close()
+
+ return Promise.resolve(resources)
}