Skip to content

Commit ebddada

Browse files
Merge pull request #49 from timonbandit/master
Added error handling on timeout while getting css. Updated outdated dependencies.
2 parents b512d52 + 868518c commit ebddada

File tree

5 files changed

+1020
-794
lines changed

5 files changed

+1020
-794
lines changed

.github/workflows/node.js.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: [14.x, 16.x, 18.x]
18+
node-version: [16.x, 18.x, 20.x]
1919
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2020

2121
steps:

lib/Constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99

1010
PRINT_BROWSER_CONSOLE: false,
1111
DROP_KEYFRAMES: true,
12-
PUPPETEER_HEADLESS: true,
12+
PUPPETEER_HEADLESS: "new",
1313
BROWSER_USER_AGENT: 'Crittr ' + package_json.version,
1414
BROWSER_CACHE_ENABLED: true,
1515
BROWSER_JS_ENABLED: true,

lib/classes/Crittr.class.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -328,20 +328,26 @@ class Crittr {
328328

329329
resolve(cssString);
330330
} else if (!this.options.css) {
331-
let cssString = await this.getCssFromUrl(this.options.urls[0]);
331+
try {
332+
let cssString = await this.getCssFromUrl(this.options.urls[0]);
332333

333-
resolve(cssString);
334+
resolve(cssString);
335+
} catch (e) {
336+
reject(e);
337+
}
334338
}
335339
});
336340
}
337341

338342
async getCssFromUrl(url) {
339343
let cssString = '';
340344
const page = await this.getPage();
341-
345+
debug('getCssFromUrl - Try to get collect CSS from ' + url);
342346
await page.coverage.startCSSCoverage();
343-
await page.goto(url, { waitUntil: 'load' });
344-
347+
await page.goto(url, {
348+
waitUntil: 'load',
349+
timeout: this.options.timeout,
350+
});
345351
cssString = await page.evaluate(() => {
346352
return [...document.styleSheets]
347353
.map(styleSheet => {

package.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "crittr",
3-
"version": "1.5.2",
3+
"version": "1.5.3",
44
"description": "Crittr is a high performance critical css extraction library with a multiple url support.",
55
"author": "Philipp Winterle",
66
"license": "GPL-3.0",
@@ -26,33 +26,33 @@
2626
"extract"
2727
],
2828
"engines": {
29-
"node": ">=14"
29+
"node": ">=16"
3030
},
3131
"main": "index.js",
3232
"dependencies": {
33-
"@types/jest": "^29.0.0",
33+
"@types/jest": "^29.5.11",
3434
"chalk": "^4.1.2",
35-
"clean-css": "^5.3.1",
35+
"clean-css": "^5.3.3",
3636
"css": "^3.0.0",
37-
"debug": "^4.3.2",
38-
"deepmerge": "^4.2.2",
39-
"fs-extra": "^10.1.0",
37+
"debug": "^4.3.4",
38+
"deepmerge": "^4.3.1",
39+
"fs-extra": "^11.2.0",
4040
"is-plain-object": "^5.0.0",
4141
"lodash": "^4.17.21",
4242
"object-hash": "^3.0.0",
43-
"postcss": "^8.4.16",
44-
"postcss-sort-media-queries": "^4.3.0",
45-
"puppeteer": "^17.1.2",
43+
"postcss": "^8.4.33",
44+
"postcss-sort-media-queries": "^5.2.0",
45+
"puppeteer": "^21.9.0",
4646
"run-queue": "^2.0.1",
4747
"signale": "^1.4.0"
4848
},
4949
"devDependencies": {
5050
"cross-env": "^7.0.3",
51-
"eslint": "^8.23.0",
52-
"eslint-config-prettier": "^8.3.0",
53-
"husky": "^8.0.1",
54-
"jest": "^28.0.2",
55-
"prettier": "^2.7.1"
51+
"eslint": "^8.56.0",
52+
"eslint-config-prettier": "^9.1.0",
53+
"husky": "^8.0.3",
54+
"jest": "^29.7.0",
55+
"prettier": "^3.2.4"
5656
},
5757
"scripts": {
5858
"test": "cross-env NODE_ENV=development jest --bail --verbose",

0 commit comments

Comments
 (0)