From 76674efe45717ad02304c4fc7e6bab7ab1485443 Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Mon, 12 Aug 2024 04:05:53 -0500 Subject: [PATCH 1/3] Bump puppeteer --- package.json | 2 +- yarn.lock | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index deca893..de659a8 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "lru-cache": "^11.0.0", "mime": "^4.0.4", "minimatch": "^10.0.1", - "puppeteer": "^22.15.0", + "puppeteer": "^23.0.2", "serve-static": "^1.15.0", "yargs": "^17.7.2" }, diff --git a/yarn.lock b/yarn.lock index 26b1218..5069193 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5271,7 +5271,7 @@ __metadata: mime: "npm:^4.0.4" minimatch: "npm:^10.0.1" nodemon: "npm:^3.1.4" - puppeteer: "npm:^22.15.0" + puppeteer: "npm:^23.0.2" serve-static: "npm:^1.15.0" supertest: "npm:^7.0.0" ts-jest: "npm:^29.2.4" @@ -6590,16 +6590,16 @@ __metadata: languageName: node linkType: hard -"chromium-bidi@npm:0.6.3": - version: 0.6.3 - resolution: "chromium-bidi@npm:0.6.3" +"chromium-bidi@npm:0.6.4": + version: 0.6.4 + resolution: "chromium-bidi@npm:0.6.4" dependencies: mitt: "npm:3.0.1" urlpattern-polyfill: "npm:10.0.0" zod: "npm:3.23.8" peerDependencies: devtools-protocol: "*" - checksum: 10/5a4dd35a09cc26c6610883055dfda4212a09d761aa020bcbcf96824bea008e34a48fef712af40a2e07e804fff7302d0213233292a63b868605beba63320601f4 + checksum: 10/b7abf812793861e20698a5a758775d0d15300c968dc1a7177238fdcc76ba66946e7cde9c6dd822aa11de3f79d64c883990e32c9d151802b82827e96226a85430 languageName: node linkType: hard @@ -13357,30 +13357,31 @@ __metadata: languageName: node linkType: hard -"puppeteer-core@npm:22.15.0": - version: 22.15.0 - resolution: "puppeteer-core@npm:22.15.0" +"puppeteer-core@npm:23.0.2": + version: 23.0.2 + resolution: "puppeteer-core@npm:23.0.2" dependencies: "@puppeteer/browsers": "npm:2.3.0" - chromium-bidi: "npm:0.6.3" + chromium-bidi: "npm:0.6.4" debug: "npm:^4.3.6" devtools-protocol: "npm:0.0.1312386" ws: "npm:^8.18.0" - checksum: 10/904d98673c1a96373cd3d29e296708bf0a6e7f1c945591fa7848af74f86a415fdd677db908dedf2257aeb88f8131cfdadeb81d81ba8740cca1f65bb05f83834c + checksum: 10/cdb007c1f0ece6f08f3bcb7026a1ce4cc0c1b7b6f1099ed626ad861100062faef10b098a8170ae3433ea41dd8a0bbd0c31ef79fa57f8fdd3087fb6a24286cbac languageName: node linkType: hard -"puppeteer@npm:^22.15.0": - version: 22.15.0 - resolution: "puppeteer@npm:22.15.0" +"puppeteer@npm:^23.0.2": + version: 23.0.2 + resolution: "puppeteer@npm:23.0.2" dependencies: "@puppeteer/browsers": "npm:2.3.0" + chromium-bidi: "npm:0.6.4" cosmiconfig: "npm:^9.0.0" devtools-protocol: "npm:0.0.1312386" - puppeteer-core: "npm:22.15.0" + puppeteer-core: "npm:23.0.2" bin: - puppeteer: lib/esm/puppeteer/node/cli.js - checksum: 10/500ea99250e2a48ef3e943c82b5d3983db846e0083863dd57086874db19d6e9ac0bf03c31bc80fa1154e795e3904820e1fe0a9052a454206cfb411f0b57ff70f + puppeteer: lib/cjs/puppeteer/node/cli.js + checksum: 10/9d5b8c6ceaa0c7c2d20e3790c4924b2022bf61030f61c6ff4fb26efd118c6f2f272ec3bfae741949eabadedd3b8dc06af0c0c853aaf7f9230c665495d0275168 languageName: node linkType: hard From bb6e688aba75c0179137930d3ec493bc4bfe71bc Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Mon, 12 Aug 2024 04:06:10 -0500 Subject: [PATCH 2/3] Update return type to be more narrow --- src/modules/metaServer/lib/image/generateImageFromPage.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/metaServer/lib/image/generateImageFromPage.ts b/src/modules/metaServer/lib/image/generateImageFromPage.ts index 5013e1f..7b6b21b 100644 --- a/src/modules/metaServer/lib/image/generateImageFromPage.ts +++ b/src/modules/metaServer/lib/image/generateImageFromPage.ts @@ -19,7 +19,7 @@ export const generateImageStringFromPage = (page: Page, screenshotOptions: Scree return page.screenshot(options) } -export const generateImageBufferFromPage = (page: Page, screenshotOptions: ScreenshotOptions = defaultScreenshotOptions): Promise => { +export const generateImageBufferFromPage = (page: Page, screenshotOptions: ScreenshotOptions = defaultScreenshotOptions): Promise => { const options = { ...screenshotOptions, encoding: 'binary' } as const return page.screenshot(options) } @@ -27,7 +27,7 @@ export const generateImageBufferFromPage = (page: Page, screenshotOptions: Scree export const generateImageFromPage = ( page: Page, screenshotOptions: ScreenshotOptions = defaultScreenshotOptions, -): Promise => { +): Promise => { return page.screenshot(screenshotOptions) } @@ -35,8 +35,8 @@ export const renderAndGenerateImageFromPage = async ( url: string, pageRenderingOptions: PageRenderingOptions = defaultPageRenderingOptions, screenshotOptions: ScreenshotOptions = defaultScreenshotOptions, -): Promise => { - let image: Buffer | string | undefined = undefined +): Promise => { + let image: Uint8Array = new Uint8Array(0) await usePage(url, pageRenderingOptions, async (page: Page) => { image = await generateImageFromPage(page, screenshotOptions) }) From 56fd552af61e675d4421aa9197b03b6ea2979922 Mon Sep 17 00:00:00 2001 From: Joel Carter Date: Mon, 12 Aug 2024 04:08:25 -0500 Subject: [PATCH 3/3] Rename option https://github.com/puppeteer/puppeteer/pull/12756 --- src/modules/metaServer/lib/browser/useBrowser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/metaServer/lib/browser/useBrowser.ts b/src/modules/metaServer/lib/browser/useBrowser.ts index 1a63460..27c4ed9 100644 --- a/src/modules/metaServer/lib/browser/useBrowser.ts +++ b/src/modules/metaServer/lib/browser/useBrowser.ts @@ -33,11 +33,11 @@ process.env.PUPPETEER_DISABLE_HEADLESS_WARNING = 'true' export const useBrowser = async (viewport: Viewport = viewPortDefaults): Promise => { const defaultViewport: Viewport = { ...viewPortDefaults, ...viewport } const browser = await launch({ + acceptInsecureCerts: true, args: getBrowserArgs(), defaultViewport, devtools: false, headless: true, - ignoreHTTPSErrors: true, waitForInitialPage, }) return browser