Skip to content

close browser onerror #40

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

Merged
merged 1 commit into from
Nov 25, 2021
Merged
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
20 changes: 11 additions & 9 deletions api/_chromium.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})`
Expand All @@ -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 <style> and <link> CSS,
Expand Down Expand Up @@ -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)
}