addyosmani / addyosmani/critical

Critical fails with net::ERR_ABORTED at file:///*/*.html when making critical CSS for multiple dimensions.

オープン
#618 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
JavaScript
スター
10.3k
フォーク
390
PR マージ指標
30日以内にマージされた PR はありません

説明

I don't know if it is a bug or if I'm doing something wrong, but on the critical version 4.0.0, my code works just fine. It looks like this:

```
`const puppeteer = require("puppeteer");

async function testPenthouseWithRealUserAgent() {
const { generate } = await import("critical");
const browser = await puppeteer.launch({
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
headless: false,
args: [
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-dev-shm-usage",
"--disable-blink-features=AutomationControlled",
],
});

try {
console.log('🚀 Testing critical with real user agent...');

const criticalCSS = await generate({
src: 'https://example.com',
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
strict: false, // Don't break on CSS parsing errors
request: {
https: {
rejectUnauthorized: false // Handle TLS certificate issues
}
},
penthouse: {
blockJSRequests: false,
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
puppeteer: {
getBrowser: () => {
console.log('Returning existing browser instance to penthouse');
return browser;
},
},
},
dimensions: [
{
width: 1300,
height: 900,
},
{
width: 375,
height: 667,
}
],
});

console.log('📊 Critical CSS result:', criticalCSS);
console.log('📊 Critical CSS length:', criticalCSS.css ? criticalCSS.css.length : 'No CSS');
console.log('📄 First 200 chars:', criticalCSS.css ? criticalCSS.css.substring(0, 200) : 'No CSS');
} catch (error) {
console.log('❌ Penthouse failed:', error.message);
}

await browser.close();
}`
```

The same code when upgraded to version 7.2.1 throws error:
net::ERR_ABORTED at file:///private/var/folders/w0/h7jgcvv57c39qxjq7_snr5q00000gn/T/0118f06a51def9c16c12b60cf64a8f79/b68014cf31423d469b1bfc0c5875fe5b.html

Debugging logs show that critical makes cleanup after successfully making CSS for the first dimension. When it tries to make it for the second dimension, it is not able to read the HTML since it was already deleted.

The question is: Was the creation of CSS for multiple dimensions changed from v4 to v7, or is this a bug?

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。