From 13227416c05e2eae5a1a99e5d5f3396679e83d89 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Mon, 30 Sep 2024 19:54:24 +0800 Subject: [PATCH] chore: upgrade puppeteer usage to fit new version --- src/server/utils/screenshot/lighthouse.ts | 7 ++++++- src/server/utils/screenshot/website.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/server/utils/screenshot/lighthouse.ts b/src/server/utils/screenshot/lighthouse.ts index 5a44b5f..560fc60 100644 --- a/src/server/utils/screenshot/lighthouse.ts +++ b/src/server/utils/screenshot/lighthouse.ts @@ -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 { + 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'], diff --git a/src/server/utils/screenshot/website.ts b/src/server/utils/screenshot/website.ts index 97689fc..66a0fb3 100644 --- a/src/server/utils/screenshot/website.ts +++ b/src/server/utils/screenshot/website.ts @@ -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 {