chore: upgrade puppeteer usage to fit new version

This commit is contained in:
moonrailgun 2024-09-30 19:54:24 +08:00
parent f59793d6f1
commit 13227416c0
2 changed files with 7 additions and 2 deletions

View File

@ -1,13 +1,18 @@
import puppeteer from 'puppeteer';
import lighthouse, { Result, generateReport } from 'lighthouse';
import { logger } from '../logger.js';
import { env } from '../env.js';
export async function generateLighthouse(url: string): Promise<Result> {
logger.info('[Lighthouse] Generating Lighthouse report...', { url });
// Use Puppeteer to launch headless Chrome
// - Omit `--enable-automation` (See https://github.com/GoogleChrome/lighthouse/issues/12988)
// - Don't use 800x600 default viewport
const browser = await puppeteer.launch({
// Set to false if you want to see the script in action.
headless: 'new',
executablePath: env.puppeteerExecutablePath,
headless: true,
args: ['--no-sandbox', '--single-process', '--disable-dev-shm-usage'],
defaultViewport: null,
ignoreDefaultArgs: ['--enable-automation'],

View File

@ -12,7 +12,7 @@ export async function screenshotWebsiteDetailImage(
) {
const browser = await puppeteer.launch({
executablePath: env.puppeteerExecutablePath,
headless: 'new',
headless: true,
});
const page = await browser.newPage();
try {