From c03289d77ddeffcc2151594a49af213831e3e299 Mon Sep 17 00:00:00 2001 From: Adam Baker Date: Mon, 6 May 2024 13:11:55 -0400 Subject: [PATCH] upgrade to node 20 and other misc improvements --- .github/workflows/ci.yml | 2 +- package.json | 2 +- src/services/pdf-generation.ts | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb0b693..4419a2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - uses: volta-cli/action@v1 with: - node-version: 18.x + node-version: 20.x yarn-version: 1.x - name: Install Dependencies run: yarn install diff --git a/package.json b/package.json index 15d7c39..3769076 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "access": "public" }, "volta": { - "node": "18.16.0", + "node": "20.9.0", "yarn": "3.6.4" } } diff --git a/src/services/pdf-generation.ts b/src/services/pdf-generation.ts index d105294..f40199f 100644 --- a/src/services/pdf-generation.ts +++ b/src/services/pdf-generation.ts @@ -1,3 +1,4 @@ +import { executablePath } from 'puppeteer'; import puppeteer, { PDFOptions } from 'puppeteer-core'; import report from 'puppeteer-report'; @@ -41,11 +42,12 @@ export default class PdfGenerationService { } async launchBrowser(pdfGenerationRequest: PdfGenerationRequest) { - const chromiumPath = await chromium.executablePath(); + const chromiumPath = process.env.IS_LOCAL ? executablePath() : await chromium.executablePath(); const options = { - args: chromium.args, + args: process.env.IS_LOCAL ? process.env.BROWSER_ARGS?.split(',') ?? ['--no-sandbox'] : chromium.args, + defaultViewport: chromium.defaultViewport, executablePath: chromiumPath, - headless: !!process?.env?.BROWSER_HEADLESS === false ? false : true, + headless: chromium.headless as boolean, ...pdfGenerationRequest.browserOptions };