Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update chromium and node #22

Merged
merged 5 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
- uses: actions/checkout@v3
- uses: volta-cli/action@v1
with:
node-version: 14.x
node-version: 18.x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should upgrade to use 20

yarn-version: 1.x
- name: Install Dependencies
run: yarn install --frozen-lockfile
run: yarn install
- name: Lint
run: yarn lint
- name: Run Tests
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
.idea/*

.DS_Store
.yarn
coverage
*.log
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
coverage
*.log
.gitlab-ci.yml
.yarn

yarn.lock
/*.tgz
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.56.0",
"@aws-sdk/s3-request-presigner": "^3.120.0",
"chrome-aws-lambda": "^10.1.0",
"@sparticuz/chromium": "122",
"puppeteer-core": "^13.5.1",
"puppeteer-report": "^3.0.2"
},
"publishConfig": {
"access": "public"
},
"volta": {
"node": "14.19.1"
"node": "18.16.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, should use node 20

"yarn": "3.6.4"
}
}
20 changes: 11 additions & 9 deletions src/services/pdf-generation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import chromium from 'chrome-aws-lambda';
import { PDFOptions } from 'puppeteer-core';
import puppeteer, { PDFOptions } from 'puppeteer-core';
import report from 'puppeteer-report';

import chromium from '@sparticuz/chromium';

import PdfGenerationRequest from '../requests/request';

const DEFAULT_PRINT_OPTIONS: PDFOptions = {
Expand Down Expand Up @@ -29,7 +30,7 @@
});
console.log(`Puppeteer visited page located at ${pdfGenerationRequest.url}`);
const options = { ...htmlToPdfPrintOptions, ...pdfGenerationRequest.pdfOptions };
await report.pdfPage(page, {
await report.pdfPage(page as any, {

Check warning on line 33 in src/services/pdf-generation.ts

View workflow job for this annotation

GitHub Actions / Tests

Unexpected any. Specify a different type
path: pdfGenerationRequest.localFilePath,
...options
});
Expand All @@ -40,13 +41,14 @@
}

async launchBrowser(pdfGenerationRequest: PdfGenerationRequest) {
return await chromium.puppeteer.launch({
const chromiumPath = await chromium.executablePath();
const options = {
args: chromium.args,
defaultViewport: null,
executablePath: await chromium.executablePath,
headless: chromium.headless,
ignoreHTTPSErrors: true,
executablePath: chromiumPath,
headless: !!process?.env?.BROWSER_HEADLESS === false ? false : true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should follow what the spazium lib does: https://github.com/Sparticuz/chromium?tab=readme-ov-file#usage and use chromium.headless

...pdfGenerationRequest.browserOptions
});
};

return await puppeteer.launch(options);
}
}
Loading
Loading