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 1 commit
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
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
"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"
}
}
18 changes: 10 additions & 8 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 @@ -40,13 +41,14 @@ export default class PdfGenerationService {
}

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,
...pdfGenerationRequest.browserOptions
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

});
};

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